extjs extjs4 extjs-mvc

extjs - TreeGrid: la configuración de la raíz de datos no tiene efecto



extjs4 extjs-mvc (4)

Como ha configurado su lector con la root: ''data'' , debe reemplazar ''hijos'' por ''datos'' en su JSON:

{ "code": "success", "data": { "text": ".", "data": [ // << not "children" {

Estoy tratando de configurar un TreeGrid, mi objeto de datos se ve así:

{ "code": "success", "data": { "text": ".", "children": [ { "clientname": "Market", "contact": "OpenX Market Advertiser", "email": "[email protected]",

Necesito decirle a Ext que debe usar datos como elemento raíz:

var store = Ext.create(''Ext.data.TreeStore'', { model: ''Task'', proxy: { type: ''ajax'', url: ''http://localhost/rocketads/trunk/advertisers/index/stats:true/'', reader:{ type:''json'', root:''data'' } }, });

Esto no funciona para mí aunque estoy usando esto con éxito con tiendas normales.


Desafortunadamente con TreeStore, cualquier cosa que use para root también se usa como la raíz para cada nivel subsiguiente, por lo que probablemente encuentre el nodo raíz y luego no encuentre su propiedad de data . Cambie la propiedad de nivel superior de datos a secundarios o cambie cada instancia de elementos secundarios a datos.


También puedes usar esto:

reader: { type: ''json'', // See http://.com/questions/9159627/extjs-loading-tree-from-json-file-using-mvc // http://.com/questions/6263380/extjs4-json-treestore root: function(o) { if (o.data) { return o.data; } else { return o.children; } } },


Tengo el mismo problema en ExtJS 4.2. Trato de resolver este problema siguiendo el código.

Ext.define(''XZSoftware.view.sysconfig.permission.PermissionWindow'', { extend: ''Ext.window.Window'', itemid: "sysconfig-permission-window", vierConfig: { loadMask: true }, layout: { type: "fit" }, minWidth: 400, minHeight: 300, tree: null, treeStore: null, initComponent: function () { var me = this; Ext.log("initComponent()", me); me.treeStore = Ext.create("Ext.data.TreeStore", { proxy: { type: "ajax", actionMethods: { read: "POST" }, reader: { type: "json", root: "data" }, url: ''/permissiontree_load.xzsoftware?o=AAAAACB'' }, root: { text: "Premission Tree", expanded: true } }); me.tree = Ext.create("Ext.tree.Panel", { rootVisible: false, store: me.treeStore }); me.items = [ me.tree ]; this.callParent(arguments); }, Version: "1.0.0.0" });

El JSON responderá de la solicitud HTTP.

{ "total": 17, "data": [{ "data": [{ "data": [], "expanded": true, "leaf": "true", "checked": false, "text": "HSBC" }, { "data": [], "expanded": true, "leaf": "true", "checked": false, "text": "All IDoc" }, { "data": [], "expanded": true, "leaf": "true", "checked": false, "text": "ProCRM" }], "expanded": true, "leaf": "false", "checked": false, "text": "Application Portal" }, { "data": [{ "data": [], "expanded": true, "leaf": "true", "checked": false, "text": "Order List" }, { "data": [{ "data": [], "expanded": true, "leaf": "true", "checked": false, "text": "Report by monthly total" }], "expanded": true, "leaf": "true", "checked": false, "text": "Order Report" }, { "data": [], "expanded": true, "leaf": "true", "checked": false, "text": "Search" }], "expanded": true, "leaf": "false", "checked": false, "text": "CNMOT - OMS" }, { "data": [{ "data": [], "expanded": true, "leaf": "true", "checked": false, "text": "Company" }, { "data": [], "expanded": true, "leaf": "true", "checked": false, "text": "Funcation Setting" }, { "data": [], "expanded": true, "leaf": "true", "checked": false, "text": "Menu Setting" }, { "data": [], "expanded": true, "leaf": "true", "checked": false, "text": "Page Setting" }, { "data": [], "expanded": true, "leaf": "true", "checked": false, "text": "Permission" }, { "data": [], "expanded": true, "leaf": "true", "checked": false, "text": "Roles" }, { "data": [], "expanded": true, "leaf": "true", "checked": false, "text": "Users" }], "expanded": true, "leaf": "false", "checked": false, "text": "System Setting" }], "success": true, "message": "Success" }

Notas: 1.Debería configurar la configuración de la raíz en TreeStore. 2.El campo secundario en JSON necesita cambiar a la configuración raíz en proxy de la tienda. En mi muestra "niños" se establece como "datos".