This is a migrated thread and some comments may be shown as answers.

In TreeList, how to retain the sort order of child rows and sort only the parent rows?

1 Answer 165 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Nayana
Top achievements
Rank 1
Nayana asked on 11 Jan 2016, 04:05 AM

Hi,

 I have a requirement where i need to sort only the parent rows in the treeList, while the child rows retain the default ascending order. 

1. Is there a way i can use compare method to retain sort order of child rows?

2. I also have to sort the parent rows for all pages in the treeList. I have implemented pagination using the method mentioned in this thread. How can sorting on entire data set be achieved? 

I have used the sort hack mentioned in the thread:

// sort hack!
var originalSortFn = kendo.data.TreeListDataSource.fn.sort;
kendo.data.TreeListDataSource.fn.sort = function (e) {
    if (arguments.length > 0) {
        myODataSource.sort(e);
    }
  
    return originalSortFn.apply(this, arguments);
};

 But, this hack code sorts the content in the displayed page first, then takes the entire data set. As a result, we see the data getting bound twice to the treeList, first time with the sort data of current page and then with the sorted data for entire data set. How can this be avoided? I want the data to be bound only once, after the sorting of entire data set?

 I don't have a working jsfiddle example for this problem.

 

Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 13 Jan 2016, 06:45 AM

Hello Nayana,

 

To your questions:

 1. No, the widget doesn't have such functionality. It will sort all levels. In the matter of fact the levels are only UI representation of the hierarchy in the TreeListDatSource all data is flat.

 

 2. Paging for the widget is also not supported. The thread which you refer to explains why we do not support paging. The sample implementation is a custom one and not supported by us. It might be applicable for some cases, but the widget is not intended to work this way.

 

Regards,
Nikolay Rusev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
TreeList
Asked by
Nayana
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Share this question
or