2011-10-05 81 views
1

在directFn中使用TreeStore有什么正确的方法?ExtJS:directfn和TreeStore - 不加载

这里是我如何做它:

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' 
    }] 
}); 

但我没有得到任何的爱。以下是我的数据示例:

[{“method”:“getMenuItems”,“result”:{“data”:[{“leaf”:true,“checked”:false,“ categoryId“:1001,”text“:”XXXXX“}],”success“:true},”action“:”categoryController“,”tid“:1,”type“:”rpc“}]

沮丧地,如果我在数据节点中放入内容并执行简单的AJAX调用,它就可以工作。

+0

你可以给你的直接供应商配置?以及firebug/js控制台中发生了什么(警告/错误)? – Gajahlemu

+0

直接提供者是一个Java应用程序。它可以正确返回json,如上所见。如果我在加载后立即查看商店,则它有一个空的商店。没有错误(我正在使用extjs的调试) – jeffkolez

回答

1

也许尝试:

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

也有一个快速浏览一下this