feat: add interactive column sorting to pivot table
SUMMARY
This PR fix https://github.com/apache/superset/issues/23353
What was done
- Added column sorting functionality to the pivot table
- Implemented ascending (asc) and descending (desc) sorting
- Added visual indicators for sorting state (icons)
Main changes
-
New
sortDatamethod - handles sorting logic and state updates -
calculateGroupsmethod - calculates aggregated values for sorting -
sortAndCacheDatamethod - sorts hierarchical data and caches results - Visual elements - added sorting icons in column headers
Implementation features
- Sorting works with hierarchical data (including nested groups)
- Support for various subtotal configurations (
rowEnabled,rowPartialOnTop) - Caching of sorted data for performance
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
How to test
- Open pivot table with data
- Click sorting icon in column header
- Verify switching between asc/desc modes
- Ensure data sorts correctly
run superset-frontend/plugins/plugin-chart-pivot-table/test/react-pivottable/tableRenders.test.tsx
ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in SIP-59)
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
🎪 Showtime deployed environment on GHA for 33ff764
• Environment: http://34.222.110.137:8080 (admin/admin) • Lifetime: 48h auto-cleanup • Updates: New commits create fresh environments automatically
🎪 Showtime deployed environment on GHA for a3e878d
• Environment: http://34.217.107.175:8080 (admin/admin) • Lifetime: 48h auto-cleanup • Updates: New commits create fresh environments automatically
🎪 Showtime deployed environment on GHA for 0e39890
• Environment: http://44.250.71.196:8080 (admin/admin) • Lifetime: 48h auto-cleanup • Updates: New commits create fresh environments automatically
@alexandrusoare mind doing a quick review? I saw you are also working on a bunch of pivot table stuff too.
Had a look, the code looks good, one thing though, I checked and the sorting only works if you click on the arrows, can we make it so that the sorting is applied when clicking on the column?
Had a look, the code looks good, one thing though, I checked and the sorting only works if you click on the arrows, can we make it so that the sorting is applied when clicking on the column?
I thought about that too, but it won't work. The onClick method is already set in the Header, which is responsible for cross-filtering.
🎪 Showtime deployed environment on GHA for f3f6ae3
• Environment: http://54.200.178.91:8080 (admin/admin) • Lifetime: 48h auto-cleanup • Updates: New commits create fresh environments automatically
🎪 Showtime deployed environment on GHA for d8da404
• Environment: http://44.252.9.174:8080 (admin/admin) • Lifetime: 48h auto-cleanup • Updates: New commits create fresh environments automatically
🎪 Showtime deployed environment on GHA for 6a8e0bb
• Environment: http://54.185.15.180:8080 (admin/admin) • Lifetime: 48h auto-cleanup • Updates: New commits create fresh environments automatically
it will be nice if the total column also get the sorting functionality
it will be nice if the total column also get the sorting functionality
also i found clicking a sorted column does not revert to the original unsorted order