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

Kendo-Vue-Grid Way to not lose sort when datasource is refreshed?

1 Answer 211 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Faisal
Top achievements
Rank 1
Faisal asked on 18 Feb 2019, 02:27 PM
I have a kendo-vue-grid like so:

    <kendo-grid v-bind:data-source="loggedInUsers"
                v-bind:sortable-mode="'multiple'"
                v-bind:sortable-allow-unsort="false"
                v-bind:sortable-show-indexes="true"
                v-bind:height="250">
        <kendo-grid-column field="username" title="Agent Name">
        </kendo-grid-column>
        <kendo-grid-column field="count" title="Count">
        </kendo-grid-column>
    </kendo-grid>

`loggedInUsers` which is used as datasource in above contains elements like:
`{ username: 'test', count: 1 }` .

My problem is that this `loggedInUsers` array gets updated every five seconds and when it gets updated, all the sorting that is done on columns gets lost. Is there a way to preserve this sort settings?

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 20 Feb 2019, 08:14 AM
Hello Faisal,

In general, one possible approach to achieve the desired result is to use the dataBound event of the Grid to store the current sorting state in a cookie. Then, when the required event for refreshing the resource is triggered, retrieve the cookie and use the dataSource.sort() method to apply the previous sort order.

Regards,
Dimitar
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Faisal
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or