Hybrid View

  1. #1
    Sencha User
    Join Date
    Oct 2008
    Posts
    278
    Vote Rating
    0
    livinglegends is on a distinguished road

      0  

    Default 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
    Code:
    Root
          Child 1
                pqr
                xyz
                abc
         Child 2
                 xyz
                 abc
                 pqr
    Options are:
    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.

    Code:
    Root
          Child 1
                abc
                pqr
                xyz
         Child 2
                 abc
                 pqr
                 xyz
    That means, I dont want to sort Child 1 and Child 2.

  2. #2
    Sencha User
    Join Date
    Oct 2008
    Posts
    278
    Vote Rating
    0
    livinglegends is on a distinguished road

      0  

    Default


    Quote Originally Posted by livinglegends View Post
    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
    Code:
    Root
          Child 1
                pqr
                xyz
                abc
         Child 2
                 xyz
                 abc
                 pqr
    Options are:
    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.

    Code:
    Root
          Child 1
                abc
                pqr
                xyz
         Child 2
                 abc
                 pqr
                 xyz
    That means, I dont want to sort Child 1 and Child 2.
    D

  3. #3
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    94
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    Did you have a look at the API docs for Ext.tree.TreeSorter?

  4. #4
    Sencha User
    Join Date
    Oct 2008
    Posts
    278
    Vote Rating
    0
    livinglegends is on a distinguished road

      0  

    Default


    Quote Originally Posted by Condor View Post
    Did you have a look at the API docs for Ext.tree.TreeSorter?
    Yes...But it also do sorting of Child 1 and Child 2. I want to sort only leaf node.

  5. #5
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    94
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    You will have to call treeSorter.doSort on each Child node separately.

  6. #6
    Sencha User
    Join Date
    Oct 2008
    Posts
    278
    Vote Rating
    0
    livinglegends is on a distinguished road

      0  

    Default


    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

Similar Threads

  1. Replies: 4
    Last Post: 5 Jun 2009, 9:43 AM
  2. Server Side And Client Side Communication
    By YargicX in forum Community Discussion
    Replies: 3
    Last Post: 15 Apr 2008, 10:52 AM
  3. Reset Client Side Sort
    By sfwalter in forum Ext 2.x: Help & Discussion
    Replies: 8
    Last Post: 31 Oct 2007, 2:00 PM

Thread Participants: 1