ngduc / react-tabulator

React Tabulator is based on tabulator - a JS table library with many advanced features.
https://codesandbox.io/s/0mwpy612xw?module=/src/components/Home.js
MIT License
366 stars 84 forks source link

rowclick with ajax initial sort bug #245

Open doraemonxxx opened 2 years ago

doraemonxxx commented 2 years ago

rowclick event with ajax initial sorting

Environment Details

Long Description

}

Please help to fix. Thank you

doraemonxxx commented 2 years ago

UPDATE:

after some testing, found out that version 0.15.0 caused it. when I downgrade the version of react-tabulator to 0.14.5 the problems are fixed.

version 0.14.7 to higher is not compatible and has a bugs. especially the new version 0.16.1

Thanks

doraemonxxx commented 2 years ago

UPDATE:

using version 0.14.4 will have a bug also. the bug is the arrow direction and scroll will reset to initial state when clicking the row

thanks

ivanmdh commented 2 years ago

Init data as null

let data

data={data}

doraemonxxx commented 2 years ago

Hello @ivanmdh ,

Care to explain more and provide concrete or better solutions?

Btw, I'm not using state to set data for tabulator. Please disregard the data:[] in state because it is not use. I used tabulator ajax options instead.

Thanks!

ivanmdh commented 2 years ago

Hi

If you set [] in initial data, tabulator check details in the data that's pagination details, so you need set start data as null.

Tabulator as monitoring all states and redraw if detect any changes, so you need disable this functionality directly in library source.

Comment this lines:

if (!isSameArray(prevState.columns, this.state.columns)) { // only when data is really different: call this.table.setData (will re-render table) this.table && this.table.setColumns(this.state.columns); } if (!isSameObject(prevState.options, this.state.options)) { // console.log('options changed', this.state.options); this.initTabulator(); }

ngduc commented 2 years ago

the behavior was: when "options" prop change, it will rerender the table. I've just added "checkOptions" prop, if set to true, then it will do that, otherwise it will not rerender the table when "options" prop change - new version 0.16.6.

Please check and let me know. Create a CodeSandbox link if it still doesn't work. Thanks.