GitHub user FrancescoCastaldi added a comment to the discussion: Table chart
paginations not reset properly on applying date range filter - version 6.1.0
This behavior in Superset 6.1.0 is caused by how table pagination state is
managed in `superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx`.
### Root Cause
The client-side `DataTable` component maintains its internal `pageIndex` in
local component state. When a date range filter is applied or cleared, the
dashboard triggers a new query and updates the `data` prop passed to
`TableChart`. However, the table component does not automatically reset
`pageIndex` back to 0 unless the current `pageIndex` exceeds the new total page
count or the component remounts. If page 3 had data originally, and after
applying the date filter the dataset shrinks to 1 page (or zero rows for that
page window), the table remains stuck requesting page index 2 (the 3rd page),
showing empty rows or "No results".
### Practical Workarounds in 6.1.0
1. **Server Pagination:**
In the chart edit view (Explore), expand the **Options** / **Customize**
section on the left panel, and switch **Server pagination** to enabled (with
Page size set explicitly). Server-side pagination synchronizes the page index
through query parameters and correctly resets the offset to 0 when the filter
payload changes.
2. **Dashboard Filter Reset:**
When testing from the dashboard, clicking **Clear all** resets the staged
filter values, but to reset the table chart state completely, use the chart's
three-dot menu and select **Force refresh**.
### Frontend Code Fix (for custom builds or PR)
If you build custom frontend assets, the fix is in `TableChart.tsx`. Adding a
`useEffect` hook that watches for query changes or data length changes resets
the table page index:
```tsx
// Inside TableChart.tsx
useEffect(() => {
gotoPage(0);
}, [data, queryData]);
```
This guarantees that whenever the filtered dataset changes, the user is
navigated back to the first page of results.
GitHub link:
https://github.com/apache/superset/discussions/45653#discussioncomment-19164443
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]