we are using kendo multiselect within a directive with some custom logic to enable support of very large lists, hence we have a backing object that stores the datasource list, and a backing model to store the selected items.When the user types into the multiselect and selects an item kendo code applies a filter to the datasource and we have mimicked this behavior to remove the fitler kendo applies like so:
dataSource.filter({});
In certain cases we need to persist the order in which the items were selected in the multiselect, the issue is that when the above code runs to apply the filter (when the user types into the multiselect and selects an item) in addition to filtering kendo applies a sort on the internal model of the datasource by default it looks like on the items property called 'Name'. In our case its sorting the int values.
Use case - Imagine you select these items in the multiselect in this sequence: 1 {Id:6, Name:John} 2 {Id:1, Name:Adam}.
the ng-model on the multiselect correctly shows [6, 1]
then user types into the multiselect and selects an item {Id: 10, Name: Steve}
then our code is called: dataSource.filter({}) as we grammatically add the selected items to the multiselect
the ng-model on the multiselect is now [1 , 6, 10] // John and Adam have swapped places due to a sort that must have happened in the filter method
Does anyone know how to filter without having the datasource automatically sort so we can persist the order in which the items were selected? I have tried to use query rather than filter on the datasource with a sort object but my model is an array of int so is becomes complicated as I would have to change these objects in the ng-model...
ref to datasource query can be seen here: http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#query
thanks!
dataSource.filter({});
In certain cases we need to persist the order in which the items were selected in the multiselect, the issue is that when the above code runs to apply the filter (when the user types into the multiselect and selects an item) in addition to filtering kendo applies a sort on the internal model of the datasource by default it looks like on the items property called 'Name'. In our case its sorting the int values.
Use case - Imagine you select these items in the multiselect in this sequence: 1 {Id:6, Name:John} 2 {Id:1, Name:Adam}.
the ng-model on the multiselect correctly shows [6, 1]
then user types into the multiselect and selects an item {Id: 10, Name: Steve}
then our code is called: dataSource.filter({}) as we grammatically add the selected items to the multiselect
the ng-model on the multiselect is now [1 , 6, 10] // John and Adam have swapped places due to a sort that must have happened in the filter method
Does anyone know how to filter without having the datasource automatically sort so we can persist the order in which the items were selected? I have tried to use query rather than filter on the datasource with a sort object but my model is an array of int so is becomes complicated as I would have to change these objects in the ng-model...
ref to datasource query can be seen here: http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#query
thanks!