Nevron Forum

Problems with sorting and grouping in NTreeList control

https://www.nevron.com/Forum/Topic4309.aspx

By Jérôme Marchaud 1 - Wednesday, October 13, 2010

We have a question regarding the NTreeList control. When the "Sorting" or "Grouping" feature is used, modifying the content of the list leads to inconsistent results.

 

If we call ClearAllNodes, and populate again the list, the column that was sorted is still marked with the up/down arrow in the header and the different color, but the content is not sorted.

 

If a column was defined as a grouping column, it disappears.

 

Is there a way to have the nodes still sorted/grouped according to the current sorting/grouping column?

 

Thank you in advance.

Best regards.

By Nevron Support - Thursday, October 14, 2010

Hi Jérôme,

To sort and group by the nodes after the nodes recreation you can do the following:

nTreeList1.ClearAllNodes();
PopulateTreeList();
//Populates the tree list again.


for (int i = 0; i < nTreeList1.Columns.Count; i++)
{
    NTreeListColumn column = nTreeList1.Columns[i];
    if (column.SortMode != TreeListSortMode.None)
    {
        nTreeList1.SortColumn(column, column.SortMode);
    }
    if (column.IsGroupedBy)
    {
        nTreeList1.Ungroup(column);
        nTreeList1.GroupBy(column);
    }
}