Download TreeStore right away. Extjs 4

My question is: how can I load TreeStore right away? Because right now, if I use a proxy to get the tree after rendering, when I open the sheet, there is another request with the GET parameter 'node' - the id of the sheet node. Therefore, I need to answer from the tree of this sheet. but I want to load ALL the tree at once and more requests for this tree.

Right now I have the code below:

  Ext.define('AdminPanel.TreeNavigation', { extend: 'Ext.data.Model', fields: ['id', 'text', 'leaf', 'children'] }); var store = Ext.create('Ext.data.TreeStore', { model: 'AdminPanel.TreeNavigation', proxy: { type: 'ajax', url : 'admin/getTreeNav', reader: { type: 'json', root: 'result' } }, root: { expanded: true } }); 
+4
source share
2 answers

In the store, I set the root of the reader as the β€œresult”.

But in json_data I sent the attribute "children", for example:

 { "result": [{ "text": "\u041d\u043e\u0432\u043e\u0441\u0442\u0438", "leaf": true, "children": [] }, { "text": "\u0410\u043a\u0446\u0438\u0438", "leaf": true, "children": [] }, { "text": "\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438", "leaf": true, "children": [] }, { "id": "lang", "text": "\u042f\u0437\u044b\u043a", "leaf": false, "children": [{ "text": "\u041a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b", "leaf": true, "children": [] }] }] } 

But you need this:

 { "result": [{ "text": "\u041d\u043e\u0432\u043e\u0441\u0442\u0438", "leaf": true, "result": [] }, { "text": "\u0410\u043a\u0446\u0438\u0438", "leaf": true, "result": [] }, { "text": "\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438", "leaf": true, "result": [] }, { "id": "lang", "text": "\u042f\u0437\u044b\u043a", "leaf": false, "result": [{ "text": "\u041a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b", "leaf": true, "result": [] }] }] } 

So, Tree will load all the data into the TreePanel.

+2
source

You need the child nodes to be sent from the server in the children regressive array. You do not need leaf and child attributes on the model, since the model will be automatically wrapped by the NodeInterface class, which will have these and other attributes (see the API for a full list of attributes)

0
source

All Articles