How to reset the grid page number after filtering?

1 Answer 6 Views
Filter  Grid
Thomas
Top achievements
Rank 1
Iron
Thomas asked on 16 May 2025, 01:38 PM | edited on 16 May 2025, 01:51 PM
Is it possible to reset the grid page number after performing a filter? We're seeing a bug where if the initial grid load has n pages and you navigate to the nth page, but then filter so there's less than n pages, the grid becomes blank and doesn't show data again until you click on one of the page numbers again. Ideally I'd like to reset the user to the first page upon filtering.

1 Answer, 1 is accepted

Sort by
0
Hetali
Telerik team
answered on 19 May 2025, 03:07 PM

Hello Thomas,

Thank you for reaching out.

When you use the autoProcessData props, the Grid automatically updates the data and the page number as seen below:

<Grid
  data={data}
  autoProcessData={true}
  defaultSkip={0}
  defaultTake={10}
  pageable={true}
  filterable={true}
>
</Grid>

In this StackBlitz example, the Grid performs the data operations automatically.


When you manually perform the data operations, use the onDataStateChange event to update the data using the process method. For example:

<Grid
  data={data}
  skip={state.skip}
  take={state.take}
  filter={state.filter}
  pageable={true}
  filterable={true}
  onDataStateChange={dataStateChange}
>
</Grid>
const [state, setState] = React.useState({
  skip: 0,
  take: 10
});

const data = process(products, state);  

const dataStateChange = (event: GridDataStateChangeEvent) => {
  setState(event.dataState);
}

In this StackBlitz example, the Grid manually updates the data.

Both the approaches go to page 1 upon filtering. Please give them a try and let me know if I can further assist you.

If you continue to have paging issues upon filtering, please update the example such that it replicates the behavior or share an isolated application, I can then investigate the matter.

Looking forward to hearing from you.

Regards,
Hetali
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
Filter  Grid
Asked by
Thomas
Top achievements
Rank 1
Iron
Answers by
Hetali
Telerik team
Share this question
or