[英]Sort an antd (Ant Design) table that has selection enabled
I am trying to make a table with antd that allows sorting and row selection (using checkboxes).我正在尝试使用 antd制作一个表格,允许排序和行选择(使用复选框)。
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.为了解决这个问题,我尝试制作一个自定义排序函数,该函数可以像排序表行一样对
selectedRowKeys
进行排序,但是我无法在回调函数中检索我需要的信息来执行此操作。
Has anyone ever done this before?以前有人这样做过吗?
Any help would be appreciated!任何帮助,将不胜感激!
You have not set the key of rows.您尚未设置行的键。 You have two ways to do it:
你有两种方法可以做到:
key
properties (with a property that represents a row identifier)key
属性(具有表示行标识符的属性)rowKey
props for the table with the name of the property that represents a row identifier in the columns objectsrowKey
道具
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.