Treegrid無法正確呈現。下面是代碼:從extjs中的json屬性文件中以dyanamically方式加載treegrid數據
treeGrid.js:
Ext.define('App.view.DBStatusGrid', {
extend : 'Ext.container.Container',
xtype : 'app-DB-grid',
layout : 'vbox',
items : [
{
xtype : 'container',
cls : 'boxTitle',
html : 'DB Details'
},
{
xtype : 'treepanel',
singleExpand: true,
useArrows:true,
rootVisible:false,
columns: [
{text: 'Server Status', dataIndex: 'serverStatus' , width: 80,},
{ xtype: 'treecolumn',text: 'Server Name', dataIndex: 'serverName' , width: 140},
{ text: 'Instance Status', align:'center', dataIndex: 'instanceStatus',width: 80,},
{text: 'Instance Name', align:'center', dataIndex: 'instanceName',width: 140}
]
}
]
});
property.json:
"data":[
{
"serverStatus": "active",
"serverName":"rg0C1",
"iconCls":"task-folder",
"expanded":false,
"data": [
{
"instanceStatus": "active",
"instanceName":"OA1",
"leaf":true,
"iconCls":"no-icon"
}
]
}
]
創建商店
Ext.define('App.view.InnerContainerView', {
extend : 'Ext.container.Container',
xtype : 'app-inner-ContainerView',
config : {
component : 'NONE',
parentView : ''
},
initComponent : function() {
var parentView = this.getParentView();
this.items = [
{
xtype : 'container',
layout: 'card',
items : [
{
xtype: 'app-DB-grid',
parentView: parentView,
listeners :{
render : function(){
var store = Ext.create('Ext.data.TreeStore',
{
model: 'App.model.treeModel',
autoLoad: true,
proxy: {
type: 'ajax',
url:'app/data/property.json',
reader: {
type: 'json',
root : 'data'
}
},
root :{
expanded :true
}
});
this.down('treepanel').setRootNode(store.getRootNode()); // I am getting my treegrid,and setting the rootnode.
}
]
}
]
this.callParent();
});
我的問題:
從JSON屬性文件,只有ServerName是越來越顯示在treegrid.When我嘗試展開ServerName,它是沒有得到expanded.Please幫我解決這個issue.Please點我正確的方向,如果我錯了某處。任何幫助將不勝感激。謝謝。
您顯示的這個initComponent方法屬於哪個組件?考慮到你沒有調用超級方法('this.callParent()'),人們可以合理地期望該組件是borken。 – rixo
@rixo我編輯了問題。謝謝。在這裏我正在顯示Server1,但其子節點沒有顯示。但在控制檯中,當我查看store.getRootNode()時,我能夠看到childnodes。 – Dev