1
votes

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. 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.

1
can you give your direct provider configuration? and what happen(warning/error) in the firebug/js console?Gajahlemu
The direct provider is a Java app. It returns the json properly as you can see above. If I view the store right after it loads, it has an empty store. No errors are thrown (I'm using the debug of extjs)jeffkolez

1 Answers

1
votes

Maybe try:

    reader:{
        type:'json',
        root:'data'
    }

Also have a quick look at this.