ExtJS: directfn and TreeStore - not loading
What's the right way to use a TreeStore with directFn?
Here's how I'm doing it:
var categoryStore = Ext.create('Ext.data.TreeStore', {
//storeId:'categoryStore',
autoLoad:true,
root: {
text: 'Menu',
id: 'categoryId',
expanded: true
},
proxy: {
type: 'direct',
directFn: categoryController.getMenuItems,
reader: {
id: 'categoryId'
}
},
fields: ['categoryId', 'text', 'children', 'leaf', 'cls'],
sorters: [{
property: 'leaf',
direction: 'ASC'
}, {
property: 'text',
direction: 'ASC'
}]
});
But I get no love.开发者_如何学Python Here's sample of my data:
[{"method":"getMenuItems","result":{"data":[{"children":[{"leaf":true,"checked":false,"categoryId":1001,"text":"XXXXX"}],"success":true},"action":"categoryController","tid":1,"type":"rpc"}]
Frustratingly, it works if I put what's inside the data node and do a straightforward AJAX call.
Maybe try:
reader:{
type:'json',
root:'data'
}
Also have a quick look at this.
精彩评论