My question is pretty simple. I want to check/select row on click. How can I do that without overthinking the whole thing? Thank you for any advice.
Solved using option : rowsSelected as it is simple array of selected options and onRowClick method.
its not so simple as soon as I click to any sorting - indexes are messed up. How can I implemented this feature as easy as possible please?
onRowClick will fire whenever you select a row, and it contains the rowMeta argument with dataIndex and rowIndex values. The rowIndex is the current row as it is currently ordered, so it will change if you've sorted the row. dataIndex is the initial ordering of the rows, so it will be constant despite sorting.
You can use the dataIndex value to determine the initial index of the selected row.
I did it as you said, works perfectly. It took me a little while to figure it out. Thank you for the exact answer. Hopefully, it will serve others. I think that this could be added as an option as well.
I'm glad that helped! I had a similar issue at one point and it also took me a little bit to figure out. I think the docs could be improved by explaining what rowIndex and dataIndex are, as those explanations are not currently in the README.
Most helpful comment
onRowClickwill fire whenever you select a row, and it contains therowMetaargument withdataIndexandrowIndexvalues. TherowIndexis the current row as it is currently ordered, so it will change if you've sorted the row.dataIndexis the initial ordering of the rows, so it will be constant despite sorting.You can use the
dataIndexvalue to determine the initial index of the selected row.