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,251
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      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,251
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      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

  7. #7
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,251
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      0  

    Default


    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.

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

      0  

    Default


    what should I write in shortFn? what can be the parameter of it?

    plz give me code?

  9. #9
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,251
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      0  

    Default


    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.

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

      0  

    Default


    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

  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

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar