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

Saving the items order

1 Answer 16 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Cristian
Top achievements
Rank 1
Cristian asked on 08 Oct 2020, 07:09 PM

     I started using the TreeList and this happens:

  • I have a list of items (columns: Name and CreatedDate)
  • I sort the list by CreatedDate DESC
  • The order of the items updates accordingly
  • I click on an item and view the details page
  • Go back to the list
  • The order is reset again

Is it possible to save the current order so that when you go back to the list it remembers the changes you made?

1 Answer, 1 is accepted

Sort by
0
Anton Mironov
Telerik team
answered on 13 Oct 2020, 05:13 PM

Hello Cristian,

Thank you for the provided reproducing steps.

In order to achieve the desired behavior, I would recommend saving the needed sorting parameters in a local storage. When the state needs to be kept, use the following:

https://docs.telerik.com/kendo-ui/api/javascript/data/datasource/methods/sort

var treeList = $("#treeList").data("kendoTreeList");
var sortParameters;

sortParameters = treeList.dataSource.sort();

To set the saved sorted state options use:

treeList.dataSource.sort(sortParameters);

The complete implementation of the approach could be found in the following dojo example:

I hope this information helps.

 

Kind Regards,
Anton Mironov
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

Tags
TreeList
Asked by
Cristian
Top achievements
Rank 1
Answers by
Anton Mironov
Telerik team
Share this question
or