react-bootstrap-table2
react-bootstrap-table2 copied to clipboard
is it possible to listen to sort changes in the tables ?
I want to remember last field and its order that was sorted by users, so when users close the page and return back then they can see the last sort state. onTableChange callback works only with remote option set to true, but I need internal react-bootstrap-table sorting. Is it possible to implement with react-bootstrap-table2?
Have a look at https://react-bootstrap-table.github.io/react-bootstrap-table2/storybook/index.html?selectedKind=Sort%20Table&selectedStory=Sort%20Events&full=0&addons=1&stories=1&panelRight=0&addonPanel=storybook%2Factions%2Factions-panel
There is a code shown that might match your needs:
const columns = [{
dataField: 'id',
text: 'Product ID',
sort: true
}, {
dataField: 'name',
text: 'Product Name',
sort: true,
onSort: (field, order) => {
console.log(....);
}
}, {
dataField: 'price',
text: 'Product Price'
}];
Thanks, @donkeyDau! I remember that I found some solution(was long time ago, don't remember exactly). Probably the same as you mentioned in the comment. I'm closing the question.