react-bootstrap-table2 icon indicating copy to clipboard operation
react-bootstrap-table2 copied to clipboard

is it possible to listen to sort changes in the tables ?

Open gyerzh opened this issue 3 years ago • 1 comments

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?

gyerzh avatar Feb 15 '22 10:02 gyerzh

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'
}];

donkeyDau avatar Mar 04 '22 13:03 donkeyDau

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.

gyerzh avatar Nov 25 '22 04:11 gyerzh