How can I reset page only when I filter?

41 views Asked by At

I'm using react table but i'm facing this issue

In case the link doesn't exist :

github_img

If I understand they add autoResetPage but I don't want to reset my page when I change the data I want to reset the page only when I filter and the page is empty so it will go to the last page with rows.

My globalfilter :

<MaterialUI.Input
sx={{ fontSize :'12px' }}
value={globalFilter || ""}
onKeyDown={(e) => {
    if (e.keyCode ==13) {
        e.preventDefault()
    } }}
onChange={(e) => {
    setGlobalFilter(e.target.value) 
}}
startAdornment={<i className="fas fa-search" style={{ marginRight:'10px' }}></i>}
placeholder={`${count} référence${count > 0 ? 's' : ''}`} />

My pagination :

<MaterialUI.Pagination count={Math.ceil((rows.length / pageSize))}
    page={pageIndex+1}
    onChange={onChangeInInput} sx={{display : 'inline-block'}}
    renderItem={(item) => ( <MaterialUI.PaginationItem sx={{fontSize : '12px'}}
                                slots={{ previous: '<', next: '>' }}
                                {...item} /> )} />

For specific filter I use the prop setAllFilters

0

There are 0 answers