Find the page a row is on, move to the page, and scroll to the row.

1 Answer 109 Views
Grid
Marvin
Top achievements
Rank 1
Iron
Iron
Marvin asked on 22 Jun 2022, 05:22 AM

Hello!

I would like to find the page that a specific row is on, move to that page, and then scroll the grid to that specific row with it selected.

It seems this isn't natively supported yet, so I'm trying to implement it myself.

My steps are thus:

1. Run my data through the filterBy and orderBy functions to obtain all the rows in the order they will appear in the grid.  (i do this using the grid's current filter and sort state).

2. Take the array of results from step 1 and call findIndex to find the index of the specific row I am interested in.

3. Update the gridState.skip setting to the index found in step 2.

4. Run my data through process using the gridState from step 3.

5. Update my bound observable with the processed data.

My result however is that the page does not change as expected.  For example, my grid is sorted by the first column and the first row is selected and when I click the column header to reverse the sort direction I am expecting the page to change to the last page and the first row to then be the last row on that page.

Does my approach seem correct?  

Thanks,

Marvin

1 Answer, 1 is accepted

Sort by
1
Martin Bechev
Telerik team
answered on 24 Jun 2022, 01:24 PM

Hi Marvin,

Thank you for the provided steps.

Updating the skip property of the Grid in order to change the page manually is the correct approach. Basically each time when the page should be changed manually based on some custom logic, the skip property should be updated accordingly.

In order to accomplish the desired behavior change the skip value when the sorting direction is reversed (like in step 3). 

Regards,
Martin
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Grid
Asked by
Marvin
Top achievements
Rank 1
Iron
Iron
Answers by
Martin Bechev
Telerik team
Share this question
or