Ext.define('Tree', {
extend: 'Ext.data.Model',
fields: [
{name: 'rw_id', type: 'string'},
{name: 'rw_name', type: 'string'},
{name: 'id', type: 'string'},
{name: 'parentid', type: 'string'},
{name: 'leaf', type: 'boolean'},
{name: 'rw_mustdata', type: 'string'},
{name: 'rw_sfwcname', type: 'string'}
]
});
var store = Ext.create('Ext.data.TreeStore',{
model: 'Tree',
proxy : {
type : "ajax", //获取方式
url : url //获取树节点的地址
}
}).load();
加载出来数据不显示
到底是TreeStore,出问题了还是?
//java类是这样写的,用的struts2
public class Tree {
private String id;
private String parentid;
private String rw_id;
private String rw_name;
private Boolean leaf;
private String rw_mustdata;
private String rw_sfwcname;
}
很急,求解释
root : {
expanded : true
},
autoLoad : true
struts2返回的数据是什么
Ext.define('AM.model.JokeModel4Tree',{
extend:'Ext.data.Model',
fields:[
{name:'id',type:'auto'},
{name:'menuBean',type:'auto'},
{name:'text',type:'auto'},
{name:'cls',type:'auto'},
{name:'leaf',type:'auto'},
{name:'type',type:'auto'},
{name:'children',type:'auto'}
]
});Ext.define('AM.store.DeptStore4Tree',{
extend:'Ext.data.TreeStore',
defaultRootId:'root',
proxy:{
type:'ajax',
url:'extjs/aja/ajax!xxx',
reader:'json'
}
})Ext.define('AM.view.JokeTree',{
extend:'Ext.tree.Panel',
alias:'widget.jokeTree',
rootVisible:true,//不展示根
displayField:'text',
title:'xx导航',
animate:false,
id:'tree-store',
store:'JokeStore4Tree'
})
Ext.define('AM.view.MainLayout',{
extend:'Ext.panel.Panel',
alias:'widget.mainlayout',
defaults:{
split:true,
bodyStyle:'padding:1px'
},
layout:'border',
resizable:true,
items:[{
title:'xx树形',
region:'west',
//iconCls:'joke-tree',
xtype:'treepanel',
margins:'5 2 5 5',
width:200,
collapsible:true,
id:'west-tree',
layout:'fit',
items:[{
title:'xx导航',
xtype:'jokeTree',
id:'joke-tree'
}]
},{
title:'数据表格',
region:'center',
//iconCls:'joke-table',
xtype:'panel',
//width:.85,
id:'center-grid',
margins:'5 5 5 0',
layout:'fit',
items:[{
title:'xx管理',
id:'joke-grid',
xtype:'jokelist'
}]
}]
})Ext.define('AM.controller.JokeController',{
extend:'Ext.app.Controller',
GridDoActionUtil:Ext.create('AM.util.GridDoActionUtils'),
init:function(){
this.getGridObj=function(button){
return button.ownerCt.ownerCt;
}
this.getTreeObj=function(button){
return button.ownerCt.ownerCt.ownerCt.ownerCt.child('#west-tree').child('#joke-tree');
}
this.getJokeEditObj = function(button){
return button.ownerCt.child('#joke-edit');
}
this.control({
'jokedit button[id=save]':{
click:function(addButton){
alert(this.getJokeEditObj);
// formBind: true,
// disabled: true,
// handler: function() {
// var fform = this.up('window').down('form').getForm();
// console.info(fform);
// if (fform.isValid()) {
// alert('1');
// fform.submit({
// url:'AppJoke/addUpdateJoke!addOrUpdate',
// success: function(fform, action) {
// Ext.Msg.alert('Success', action.result.msg);
// },
// failure: function(fform, action) {
// Ext.Msg.alert('Failed', action.result.msg);
// }
// });
// }
// }
}
},
'jokeTree':{
itemclick:function(tree,record,item,index,e,options){
var view= Ext.get('joke-view');
//var store = view.getStore();
this.GridDoActionUtil.changeTab(view,record);
}
},
"winimportview button[id=upload]":{
click: function(sm, selections,a,c){
var form=Ext.getCmp("formimport");
if (form.getForm().isValid()) {
//重置信息提示框
Ext.getCmp("resultmsg").body.update("正在导入数据,请稍候...");
form.getForm().submit({
url: Qas.getAppName() + '',
method : 'POST',
waitTitle:'请等待...',
waitMsg: '正在上传Excel文件,分析导入数据,请稍候...',
success : function(form,action) {
console.log("ServerJson="+action.response.responseText);
Ext.getCmp("resultmsg").body.update(action.result.msg);
},
failure : function(form, action){//500内部错误
console.log("ServerJson="+action.response.responseText);
Ext.getCmp("resultmsg").body.update(action.result.msg);
}
});
}
}
},
'jokelist button[id=import]':{
click:function(importButton){
var importWin = Ext.create("AM.view.WinImportView");
importWin.show();
}
},
'jokelist button[id=delete]':{
click:function(deleteButton){
var grid=this.getGridObj(deleteButton);
this.GridDoActionUtil.doDelete(grid);
}
},
'jokelist button[id=save]':{
click:function(saveButton){
var grid=this.getGridObj(saveButton);
this.GridDoActionUtil.doSave(grid);
}
},
'jokelist button[id=add]':{
click:function(addButton){
//var addWin=Ext.getCmp('joke-edit');
var win = Ext.create("AM.view.JokeEdit");
win.show();
}
}//,
//设定列表添加按钮事件
// 'jokelist button[id=add]':{
// click:function(addButton){
//
// var grid=this.getGridObj(addButton);
// var modelObj={
// id:'',
// joke:'',
// type:'',
// createTime:''
// }
// this.GridDoActionUtil.doInsert(grid,modelObj);
//
// }
// }
});
},
views:[
'MainLayout',
'JokeList',
'JokeTree',
'JokeEdit'
],
stores:[
'JokeStore4Tree',
'JokeStore'
],
models:[
'JokeModel'
]
})
1、在页面没加载完成的时候已经创建了dom元素,将元素的宽高自动设置为了0。
2、你需要重写treePanel的load方法,将node.removeAll(true)更改为node.removeAll(false)。