-
28 Dec 2012 12:53 AM #1
Answered: Serialize tree
Answered: Serialize tree
What is the recommended way to serialize a tree respectively treestore into json, so one can save the whole tree at once in localstorage, for example?
I guess the resulting json should look like this to be able to re-use it directly:
This might seem obvious, but I can't find the answer from the docs or previous posts. Isn't there anything built-in? I have created my own iteration function, but I can't imagine such a common task has to be re-built every time someone needs that...?Code:root: {text: 'root', children: [ {text: 'leaf1'}, {text: 'leaf2', children: [ {}, {}, ... ]} ]
Thanks!
-
Best Answer Posted by Animal
Hopefully, tree nodes will get the serialize method in 4.2
I have added it, just needs review and QA
-
31 Dec 2012 7:08 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,677
- Vote Rating
- 435
- Answers
- 3110
You can use the cascade method to work through the tree.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
31 Dec 2012 7:46 AM #3Sencha - Ext JS Dev Team
- Join Date
- Mar 2007
- Location
- Notts/Redwood City
- Posts
- 30,458
- Vote Rating
- 20
- Answers
- 9
Hopefully, tree nodes will get the serialize method in 4.2
I have added it, just needs review and QASearch the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
31 Dec 2012 10:51 AM #4
Nice, Animal!


Reply With Quote