-
5 Oct 2010 7:31 AM #1
How to sort tree at client side?
How to sort tree at client side?
Hi,
Is there any way to sort tree at client side using extjs?
As per requirement, I have to put two options below TreePanel.
My tree is like this
Options are:Code:Root Child 1 pqr xyz abc Child 2 xyz abc pqr
1. Sort by Name
2. Sort by Count
When user press on Sort by Name, all the nodes should be sorted by name and tree should be like below.
That means, I dont want to sort Child 1 and Child 2.Code:Root Child 1 abc pqr xyz Child 2 abc pqr xyz
-
5 Oct 2010 8:10 AM #2
-
6 Oct 2010 2:19 AM #3Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 40
Did you have a look at the API docs for Ext.tree.TreeSorter?
-
6 Oct 2010 2:21 AM #4
-
6 Oct 2010 2:25 AM #5Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 40
You will have to call treeSorter.doSort on each Child node separately.
-
6 Oct 2010 2:27 AM #6
Let me explain my full scenario.
I have one tree as shown above and one combo box with two options 1. by name and 2. by count.
When user select any option, tree should get sorted.
How, to sort tree on selection change of combobox?
Because tree get sorted when any operation fire on node.
Please give me some code hint
-
6 Oct 2010 2:32 AM #7Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 40
In that case you don't really need a TreeSorter, you just have to call sort(sortFn) on each child node from the combobox select event handler.
-
6 Oct 2010 2:36 AM #8
what should I write in shortFn? what can be the parameter of it?
plz give me code?
-
6 Oct 2010 2:40 AM #9Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 40
sortFn needs to be a function with two parameters (node1 and node2) that returns -1 if node1 should be before node2, 1 if node1 should be after node2 and 0 if the nodes are equal.
-
6 Oct 2010 2:44 AM #10
How to compare text? I want it to sort alphabetically.
One more thing:
Each node has one attribute count. I want to sort tree by count also.
Similar Threads
-
com.extjs.gxt.samples.client.examples.tree.TreeTab leExample method "sort" is empty
By fother in forum Ext GWT: Help & Discussion (1.x)Replies: 4Last Post: 5 Jun 2009, 9:43 AM -
Server Side And Client Side Communication
By YargicX in forum Community DiscussionReplies: 3Last Post: 15 Apr 2008, 10:52 AM -
Reset Client Side Sort
By sfwalter in forum Ext 2.x: Help & DiscussionReplies: 8Last Post: 31 Oct 2007, 2:00 PM


Reply With Quote