Search code examples
sortinggwtgxt

Adding node to a sorted tree store


Firstly I'm using GXT 3.1.1 with GWT 2.6.1

I have a TreeStore which displays the items at a TreeGrid component and it is sorted like below:

 //Sort the list alphabetically     
    treeStore.addSortInfo(new StoreSortInfo<BaseTreeGridDTO>(comparator, SortDir.ASC)); 

However, once it is already sorted and I add new elements to it, they are always placed at the end of the list.

Is there any way to add these new items to this sorted TreeStore where it can keep the alphabetical order?


Solution

  • If you set SortInfo for a TreeStore, this will not work. You have to set for a ListStore.

    For example, instead of using grid.getTreeStore(), use grid.getStore().