对已启用选择的antd(蚂蚁设计)表进行排序 [英] Sort an antd (Ant Design) table that has selection enabled

查看:131
本文介绍了对已启用选择的antd(蚂蚁设计)表进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用antd制作一个,该表可以进行排序和行选择(使用复选框).

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.

为解决此问题,我尝试制作一个自定义排序函数,该函数可能以与对表行进行排序相同的方式对selectedRowKeys进行排序,但是我无法在回调函数中检索需要的信息来执行此操作.

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.

以前有人做过吗?

任何帮助将不胜感激!

推荐答案

您尚未设置行键. 您有两种方法可以做到:

You have not set the key of rows. You have two ways to do it:

  • 在columns数组的对象中添加key属性(具有代表行标识符的属性)
  • 为表设置
  • set rowKey属性,该属性的名称表示列对象中的行标识符
  • 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

这篇关于对已启用选择的antd(蚂蚁设计)表进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆