Extjs treestore with proxy server

I am creating an MVC extjs application. I have a tree with storage that loads data from php source. I get the following response in json format:

[ { "text": "Home", "leaf": true, "dbName": "NULL", "children": [] }, { "text": "Moje Firma sro", "leaf": false, "expanded": false, "children": [ { "text": "Vydane", "leaf": true, "dbName": "demo" }, { "text": "Prijate", "leaf": true, "dbName": "demo" } ] }, { "text": "Já Živnostník", "leaf": false, "expanded": false, "children": [ { "text": "Vydane", "leaf": true, "dbName": "demo_de" }, { "text": "Prijate", "leaf": true, "dbName": "demo_de" } ] }, { "text": "Nezisková organizace", "leaf": false, "expanded": false, "children": [ { "text": "Vydane", "leaf": true, "dbName": "demo_neziskova" }, { "text": "Prijate", "leaf": true, "dbName": "demo_neziskova" } ] }, { "text": "Příspěvková organizace", "leaf": false, "expanded": false, "children": [ { "text": "Vydane", "leaf": true, "dbName": "demo_prispevkovka" }, { "text": "Prijate", "leaf": true, "dbName": "demo_prispevkovka" } ] }, { "text": "Moje Firma SK sro", "leaf": false, "expanded": false, "children": [ { "text": "Vydane", "leaf": true, "dbName": "demo_sk" }, { "text": "Prijate", "leaf": true, "dbName": "demo_sk" } ] } ] 

My shop:

 Ext.define('Statistics.store.Menu', { extend: 'Ext.data.TreeStore', model: 'Menu', autoLoad: true, autoSync: true, proxy : { type : 'ajax', url : 'data.json', reader: { type: 'json' } } }); 

And the model:

 Ext.define('Statistics.model.Menu', { extend: 'Ext.data.Model', fields: [ {name: 'text', type: 'string'}, {name: 'leaf', type: 'boolean'}, {name: 'expanded', type: 'boolean', defaultValue: false}, {name: 'dbName', type: 'string', defaultValue: 'NULL'} ], }); 

This configuration works when data is saved in a .json file. But id does not work when they are loaded from php source.

Thanks for any answer.

+4
source share
2 answers

The server response should look like this:

 { success: true, children: // here is the array of items } 
+4
source

Your field is named db_name, and the json response is 'dbName'. Is this a typo that you can verify?

0
source

All Articles