我的树树最初被加载,但是请求子节点失败。
当请求子数据时,将发送一个参数localpath,该参数定义子数据所在的路径。
Init请求:localpath=/ ->获取/中的所有子级
子请求:localpath=/subfolder1 ->获取/subfolder1中的所有子级
我已经附加了两个屏幕截图,显示初始加载和显示何时单击文件夹。


顺便说一句,我树上的箭在哪里?
json :我的树存储库接收这样的json数据:
{
"value": {
"name": "",
"path": "/",
"leaf": false,
"type": "folder",
"children": [
{
"name": "subfolder1",
"path": "/subfolder1",
"leaf": false,
"type": "folder",
"children": []
},
{
"name": "subfolder2",
"path": "/subfolder2",
"leaf": false,
"type": "folder",
"children": []
},
{
"name": "testreports",
"path": "/testreports",
"leaf": false,
"type": "folder",
"children": []
}
]
}
}store :树商店如下所示:
var oTreeStore = Ext.create( 'X.module.store.store.Tree', {
model : 'X.module.store.model.TreeNode',
api : this.httpApi,
module : "store",
func : "getchildren",
scope : "user"
} );TreePanel创建:
var oTreePanel = Ext.create( 'X.module.store.view.TreePanel', {
store : oTreeStore
} );TreePanel定义:
constructor: function( oConfig ) {
var self = this;
//creating a proxy, which can communicate with HTTP-API
//and is able to parse it's json-tree format
var oProxy = Ext.create( 'X.lib.httpapiclient.Proxy', {
api : oConfig.api,
module : oConfig.module,
func : oConfig.func,
params : {
scope : oConfig.scope
},
reader : {
type: 'json',
root: function( o ) { return o.value? o.value.children : o.children; }
},
delay : oConfig.delay || 100,
success : oConfig.success || function() {},
progress: oConfig.progress || function() {},
error : oConfig.error || function() {}
} );
oConfig.nodeParam = 'localpath';
oConfig.proxy = oProxy;
self.callParent( arguments );
//the HTTP-API requires the ID of the root-node to be empty
self.on( 'beforeload', function( s, o ) {
if( o.params.localpath === 'root' ) o.params.localpath = '/';
} );
}模型:模型..。
Ext.define( 'X.module.store.model.TreeNode', {
extend: 'Ext.data.Model',
fields: [
{ name: 'name', type: 'string' },
{ name: 'path', type: 'string' },
{ name: 'type', type: 'string' }
]
} );发布于 2013-03-25 16:26:53
解决方案是在children属性中提供子属性。在我的例子中,我送的是像这个children: []这样的空孩子。所以没什么可展示的。
https://stackoverflow.com/questions/11902399
复制相似问题