Ability to set/get entire configuration of the table as a single object?
See original GitHub issueWhat version of React-Table are you using?
6.7.6
What bug are you experiencing, or what feature are you proposing?
Hi,
I know this table has a capability to export default values for table and override those defaults like this:
import { ReactTableDefaults } from 'react-table'
Object.assign(ReactTableDefaults, {
defaultPageSize: 10,
minRows: 3,
// etc...
})
I also know there’s a possibility of accessing some of the current values (after user changed column width, sorted things, etc…) with provided callbacks
// Callbacks
onPageChange={(pageIndex) => {...}} // Called when the page index is changed by the user
onPageSizeChange={(pageSize, pageIndex) => {...}} // Called when the pageSize is changed by the user. The resolve page is also sent to maintain approximate position in the data
onSortedChange={(newSorted, column, shiftKey) => {...}} // Called when a sortable column header is clicked with the column itself and if the shiftkey was held. If the column is a pivoted column, `column` will be an array of columns
onExpandedChange={(newExpanded, index, event) => {...}} // Called when an expander is clicked. Use this to manage `expanded`
onFilteredChange={(column, value) => {...}} // Called when a user enters a value into a filter input field or the value passed to the onFiltersChange handler by the Filter option.
onResizedChange={(newResized, event) => {...}} // Called when a user clicks on a resizing component (the right edge of a column header)
However, I’d like the ability to be able to get all of the current values in the table, and the ability to send those values back in. Something like getTableConfig/setTableConfig. For example, this would allow people to save entire state of the table, so that people don’t have to constantly sort their tables the way they like. This could also be used to synchronize the data in table with other components on the page, for example charts. If table is only showing first ten rows, the chart could reflect that and show the same rows. If user switches page in table, it could show ten different rows and once again, the chart could reflect that.
With the ability to get current configuration of the table, it allows us to extend the functionality further and it’s also possible to persist all table settings.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
You can look at this FAQ link…
https://github.com/react-tools/react-table/wiki/FAQ#how-do-i-get-at-the-internal-data-so-i-can-do-things-like-exporting-to-a-file
The FAQ link above is broken… what would be the recommended way in v7 of saving internal data like column widths?