Add onTableChange callback on table initialization
See original GitHub issueExpected Behavior
I’m using a custom toolbar and using onTableChange
to track the table state.
I have that state as soon as the user performs a sort or filter operation, but not before then. Adding a call to onTableChange
on initialization will provide the client with the internal state to handle any custom actions on an unmodified table.
It is reasonable imo to fire the onTableChange
callback on initialization as the table state has in fact changed from uninitialized to initialized.
I created a pull request with my fix but some tests are not passing. If this is something the owners believe fits with the library I will be more than happy to work with them to fix the tests.
My change is a one-liner to add a callback to the call to setTableData
to call setTableAction
after setState
completes. setTableAction
results in onTableChange
being fired and the client receiving the initialized table state.
initializeTable(props) {
this.getDefaultOptions(props);
this.setTableOptions(props);
this.setTableData(props, TABLE_LOAD.INITIAL, () => {
this.setTableAction('tableLoadInitial');
});
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Thanks @gabrielliwerant. I’m a bit swamped today but I will look at this and come up with a pull request for onTableInit - just for the initial mounting - and add the onTableChange callback for updated props. That’s what you have in mind, yeah?
This feature is now a part of version
2.3.0
thanks to @shawndibble!