问题
I am trying to make a table with antd that allows sorting and row selection (using checkboxes).
Right now I have both enabled, however, when I sort by ascending/descending order, the selection does not sort. The checked boxes just stay at the same index as before.
To fix this I tried making a custom sort function that could possibly sort the selectedRowKeys
the same way it is sorting the table rows, but I am not able to retrieve the information I need in the callback function to do this.
Has anyone ever done this before?
Any help would be appreciated!
回答1:
You have not set the key of rows. You have two ways to do it:
- in the objects of the columns array add the
key
properties (with a property that represents a row identifier) - set
rowKey
props for the table with the name of the property that represents a row identifier in the columns objects
来源:https://stackoverflow.com/questions/50879525/sort-an-antd-ant-design-table-that-has-selection-enabled