GitHub user dosubot[bot] added a comment to the discussion: pagination in pivot 
table

<!-- Answer -->
Superset’s default pivot table plugin doesn’t support pagination or search out 
of the box because it renders all visible rows and columns directly, without 
filtering or paging logic. There’s no built-in integration with datatable or 
react-table in the pivot table code 
([source](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.jsx#L20-L936)).

If you want to add pagination and search, you can use react-table or datatable, 
but you’ll need to adapt your pivot data to a flat row/column format that these 
libraries expect. Superset’s DataTable and TableChart components are good 
references—they use react-table hooks like `usePagination` and 
`useGlobalFilter` for paging and search 
([example](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/plugins/plugin-chart-table/src/DataTable/DataTable.tsx#L20-L526)).
 You’d need to either:

- Flatten your pivoted data and render it with react-table/datatable, or
- Re-implement your pivot logic using react-table hooks for full integration.

If you go this route, you’ll need to handle UI/UX details like totals, 
subtotals, and collapsed rows/columns—these are not natively supported by 
react-table, so you may need custom logic for those features.

For implementation ideas, check out Superset’s 
[DataTable](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/plugins/plugin-chart-table/src/DataTable/DataTable.tsx#L20-L526)
 and 
[TableChart](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx#L30-L1241)
 components—they show how to wire up pagination, search, and server-side state. 
If you need to keep the pivot table’s hierarchical structure, you might need to 
look into virtualization libraries or custom wrappers.

Let me know if you want a step-by-step guide for integrating react-table or 
datatable with your pivot table!


<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*

---
<sup>How did I do? 
[Good](https://app.dosu.dev/response-feedback/59649e5e-4faf-4ee7-9603-d65d07e5ceb2?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/59649e5e-4faf-4ee7-9603-d65d07e5ceb2?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/59649e5e-4faf-4ee7-9603-d65d07e5ceb2?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/59649e5e-4faf-4ee7-9603-d65d07e5ceb2?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/59649e5e-4faf-4ee7-9603-d65d07e5ceb2?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/59649e5e-4faf-4ee7-9603-d65d07e5ceb2?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/59649e5e-4faf-4ee7-9603-d65d07e5ceb2?feedback_type=other)</sup>

[![Chat with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)&nbsp;[![Open
 in 
Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=Superset%E2%80%99s%20default%20pivot%20table%20plugin%20doesn%E2%80%99t%20support%20pagination%20or%20search%20out%20of%20the%20box%20because%20it%20renders%20all%20visible%20rows%20and%20columns%20directly%2C%20without%20filtering%20or%20paging%20logic.%20There%E2%80%99s%20no%20built-in%20integration%20with%20datatable%20or%20react-table%20in%20the%20pivot%20table%20code%20%28%5Bsource%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.jsx%23L20-L936%29%29.%0A%0AIf%20you%20want%20to%20add%20pagination%20and%20search%2C%20you%20can%20use%20react-table%20or%20datatable%2C%20but%20you%E2%80%99ll%20need%20to%20adapt%20your%20pivot%2
 
0data%20to%20a%20flat%20row/column%20format%20that%20these%20libraries%20expect.%20Superset%E2%80%99s%20DataTable%20and%20TableChart%20components%20are%20good%20references%E2%80%94they%20use%20react-table%20hooks%20like%20%60usePagination%60%20and%20%60useGlobalFilter%60%20for%20paging%20and%20search%20%28%5Bexample%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/plugins/plugin-chart-table/src/DataTable/DataTable.tsx%23L20-L526%29%29.%20You%E2%80%99d%20need%20to%20either%3A%0A%0A-%20Flatten%20your%20pivoted%20data%20and%20render%20it%20with%20react-table/datatable%2C%20or%0A-%20Re-implement%20your%20pivot%20logic%20using%20react-table%20hooks%20for%20full%20integration.%0A%0AIf%20you%20go%20this%20route%2C%20you%E2%80%99ll%20need%20to%20handle%20UI/UX%20details%20like%20totals%2C%20subtotals%2C%20and%20collapsed%20rows/columns%E2%80%94these%20are%20not%20natively%20supported%20by%20react-table%2C%20so%20you%20may%20need%20cus
 
tom%20logic%20for%20those%20features.%0A%0AFor%20implementation%20ideas%2C%20check%20out%20Superset%E2%80%99s%20%5BDataTable%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/plugins/plugin-chart-table/src/DataTable/DataTable.tsx%23L20-L526%29%20and%20%5BTableChart%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx%23L30-L1241%29%20components%E2%80%94they%20show%20how%20to%20wire%20up%20pagination%2C%20search%2C%20and%20server-side%20state.%20If%20you%20need%20to%20keep%20the%20pivot%20table%E2%80%99s%20hierarchical%20structure%2C%20you%20might%20need%20to%20look%20into%20virtualization%20libraries%20or%20custom%20wrappers.%0A%0ALet%20me%20know%20if%20you%20want%20a%20step-by-step%20guide%20for%20integrating%20react-table%20or%20datatable%20with%20your%20pivot%20table%21)&nbsp;[![Join
 Discord](https://img.shields.io/badge/join-5
 
865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share
 on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/37146)

GitHub link: 
https://github.com/apache/superset/discussions/37146#discussioncomment-15502922

----
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]

Reply via email to