-
18 Aug 2012 12:39 PM #1
Answered: Load TreeStore at once. Etxjs 4
Answered: Load TreeStore at once. Etxjs 4
Hi all.
My question is: How can I load the TreeStore at once?
Because right now, if I'm using proxy, to get Tree, after rendering, when I expand the leaf, there is one more request with GET parameter 'node' - the id of leaf node. So I need to responce with the tree of this leaf... but I want to load ALL tree at once and no more requests for that tree.
Right now I have those code:
ThanksCode: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 } });
-
Best Answer Posted by vietits
You config root: 'result' for your proxy reader, so try to change 'children' to 'result' in your json data.
Code:{ "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": [] }] }] }
-
19 Aug 2012 12:37 AM #2
How does your tree json data look like?
-
19 Aug 2012 12:56 AM #3
Here it is:
Code:{ "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": [] }] }] }
-
19 Aug 2012 1:00 AM #4
You config root: 'result' for your proxy reader, so try to change 'children' to 'result' in your json data.
Code:{ "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": [] }] }] }
-
19 Aug 2012 1:10 AM #5


Reply With Quote
