Sort an antd (Ant Design) table that has selection enabled

最后都变了- 提交于 2020-02-04 06:38:42

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!