Ext js TreeStore未加载
Ext.ns('App');
Ext.onReady(function() {
Ext.QuickTips.init();
App.PPPExplorer.init();
});
App.PPPExplorer = {
// Initialize application
init : function(serverCfg) {
this.PPP = this.createPPP();
},
createPPP : function() {
// Set up a model to use in our Store
Ext.define('Summary', {
extend: 'Ext.data.Model',
fields: [
{name: 'pid', type: 'string'}
]
});
var myStore = Ext.create('Ext.data.TreeStore', {
model: 'Summary',
storeId:'myStore',
proxy: {
type : 'ajax',
method: 'GET',
url: '/Explorer.do?method=getPPP&search=true',
reader: {
type: 'json'
},
root: {
pid: 'src',
text:'test',
expanded: true
},
},
autoLoad: true
});
Ext.create('Ext.tree.Panel', {
title: 'Simple Tree',
width: 200,
height: 150,
store: myStore,
// rootVisible: true,
renderTo: 'Explorer',
columns: [{
xtype: 'treecolumn', //this is so we know which column will show the tree
text: 'Reference',
flex: 2,
sortable: true,
dataIndex: 'pid',
locked: true
}]
});
}
}
我正在使用Ext js 4.2版本
我在上面的代码中使用了treeStore,treePanel,不知何故代理调用没有发送到Server。控制台中没有错误消息
提前致谢
答案 0 :(得分:3)
根定义应该在TreeStore 定义中,如下所示(现在在代理声明中):
var myStore = Ext.create('Ext.data.TreeStore', {
model: 'Summary',
storeId: 'myStore',
proxy: {
type: 'ajax',
method: 'GET',
url: '/Explorer.do?method=getPPP&search=true',
reader: {
type: 'json'
}
},
autoLoad: true,
root: {
pid: 'src',
text: 'test',
expanded: true
}
});
您的代码可以正常运行,see it here