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

Get global row index that is fixed regardless of filtering, pagination or sorting

Open malsioufi opened this issue 6 years ago • 1 comments

I am using "react-bootstrap-table2" package, and what I am trying to do is to copy the data from the table to other components using some global context.

Right now rowIndex acts as an index of the rows in the current page, so rowIndex=1 refers to different set of data (row) if I sort or filter or move to next page..etc.

Is there any row related argument (similar to rowIndex) that I can use as a data id for the row? This id does not change in case of filtering, pagination or whatever, it just acts like a global id. How can I get such behavior?

This is how selectRow looks like in my code. And what I am trying to do is to send the rowIndex to the global context (updatGloabalContext) so it will distribute it to other components, but the global context does not know about any table-related operations (sort, search, filter, pagination...)

selectRow = { mode: 'radio', clickToSelect: true, hideSelectColumn: true, bgColor: this.context.operationType === "red", onSelect: (row, isSelect, rowIndex, e) => { this.updatGloabalContext(rowIndex); } };

malsioufi avatar Apr 23 '20 13:04 malsioufi

I ran into a similar situation. But I maintain a list of all the rows, so I can find the global index by allRows.indexOf(row).

lacek avatar Aug 14 '20 13:08 lacek