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

Grid sorting clears data when I set pageSize: take,

1 Answer 106 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Arun
Top achievements
Rank 1
Arun asked on 02 Aug 2019, 02:46 AM

Hi, I have a grid and I need to display pagination conditionally. For some reason, if I use       pageSize: take when I do not want to paginate, sort doesnt work. I get a no records found message. But if I send in a prop to paginate, sort works. Please advice.

This is my link:

 

Link

 

Please check Line no.357 in Reusegrid.jsx file. With pageSize: take, sorting doest return data but when I remove the pageSize, sorting works but in the pageInfo, I get 1-10 of 77 items whereas I need 1-77 of 77 items. Please advice.


1 Answer, 1 is accepted

Sort by
0
Accepted
Vasil
Telerik team
answered on 05 Aug 2019, 07:57 AM
Hi,

Initially in the app these properties are passed:
{"sort":[{"field":"UnitsInStock","dir":"asc"}],"skip":0,"take":77}

But later, if sort is clicked the skip parameter is missing:
{"sort":[{"field":"UnitsInStock","dir":"desc"}],"take":77}

This looks to happen because of setSkip(e.data.skip); in dataStateChange method. Since these are the arguments during the first dataStateChange
e.data
{filter: undefined, sort: Array(1), skip: undefined, take: 77, group: undefined}


Changing setSkip(e.data.skip); to setSkip(e.data.skip || 0); will make this work. 
https://stackblitz.com/edit/react-9odprj-gncrxu?file=app/Reusegrid.jsx

Another option is to handle the undefined skip before calling the process method.

Regards,
Vasil
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
General Discussions
Asked by
Arun
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Share this question
or