-
30 Jul 2012 4:22 AM #1
Unanswered: Tree: Add node sorted
Unanswered: Tree: Add node sorted
Hi all,
Is there any way how to add node into tree with applied sort? I have defined Ext.data.TreeStore with sorter, but it is applied only when data are loaded.
If I add node into tree by parentNode.appendChild(node), the node is added as last child of parent (I know, it's append). But how I can add node according to current sort state?
I'm looking for something like Ext.data.Store.addSorted.
Thanx for advice.
-
30 Jul 2012 8:13 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,684
- Vote Rating
- 435
- Answers
- 3111
What framework and version?
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.
-
30 Jul 2012 11:47 AM #3
Sorry, I forgot mention it.
ExtJS 4.1.1.
-
30 Jul 2012 11:52 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,684
- Vote Rating
- 435
- Answers
- 3111
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 Jul 2012 1:20 AM #5
-
31 Jul 2012 4:14 AM #6
If all else fails, you always manually call the sort method of Ext.data.TreeStore, after adding your new node.
-
31 Jul 2012 6:00 AM #7
-
1 Aug 2012 12:23 AM #8
Yes, it works, but only when I use:
It is "user unfrendly" because I have to call sort manually after append.Code:Ext.getCmp('treepanel-1009').getRootNode().appendChild({text: '0a'}); Ext.getCmp('treepanel-1009').getStore().sort(this.generateComparator());
If I use store's "append" event:
I get TypeError exception:Code:var store = Ext.getCmp('treepanel-1009').getStore(); store.on('append', function () {this.sort(this.generateComparator())}, store);
Tested on xml tree example from ExtJS 4.1.1 package.Code:TypeError: sibling is undefined http://localhost/extjs_4.1.1/ext-all-dev.js Line 77912


Reply With Quote