0
我需要Extjs树面板与动态远程数据(JSON)的文件列表。Extjs 4,动态树和商店重新映射
和日期字段名称不适合Extjs树存储字段。所以我需要重新映射以适应,比如添加叶字段和文本字段。
返回JSON数据是这样的:
[{
"id":1,
"yourRefNo":"A91273",
"documentName":"Test Document",
"documentFileName":"login_to_your_account-BLUE.jpg",
"updatedBy":"root root",
"updatedAt":"\/Date(1343012244000)\/"
}]
,这是树面板:
Ext.define('App.view.Document.DocumentList', {
extend :'Ext.tree.Panel',
rootVisible : false,
alias: 'widget.Document_list',
store: 'DocumentList_store'
});
这就是商店:
Ext.define('App.store.DocumentList_store', {
extend: "Ext.data.TreeStore",
model: 'App.model.DocumentList_model',
proxy: {
type: 'ajax',
url: '/Document/GetDocumentList/',
actionMethods: {
read: 'POST'
},
reader: {
type: 'json',
root: '' // there is no root
},
pageParam: undefined,
startParam: undefined,
pageParam: undefined
},
root: {
children: []
},
autoLoad: false,
listeners: {
append: function (thisNode, newChildNode, index, eOpts) {
console.log(newChildNode.get('documentName')); // 'Test Document'
newChildNode.set('leaf', true);
newChildNode.set('text', newChildNode.get('documentName'));
// it does not add to tree panel.
}
}
});
从负载数据之后服务器,并且它很好地调用了附加功能。但在那之后,没有任何东西出现在树形面板中。
我做错了什么?请指教我。
感谢
[编辑]
这是模型,
Ext.define("App.model.DocumentList_model", {
extend: "Ext.data.Model",
fields: [
'id','yourRefNo','documentName','documentFileName','updatedBy','updatedAt'
]
});
有几件事情,可以去你的代码错误。看到你的模型定义给你一个完整的答案是有用的。但现在,我认为你忽略了一个事实,即一个树木商店用'NodeInterface'包装你的节点。鉴于此,您返回的json不适用于树。首先,你必须提供一个根节点。还有更多的事情要看,但这是一个开始。如果您提供模型定义,我们将能够进一步提供帮助。 – Izhaki 2012-07-24 09:49:04
@Izhaki我在问题的最后添加了我的模型,请您再次查看我的问题吗?感谢您的帮助! – 2012-07-24 17:30:15