开发者

ExtJS: directfn and TreeStore - not loading

开发者 https://www.devze.com 2023-04-10 18:30 出处:网络
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\', {

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号