2

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!

B--rian
  • 5,578
  • 10
  • 38
  • 89
NicoleMoore
  • 325
  • 2
  • 14
  • Related, but not a duplicate: https://stackoverflow.com/questions/59479703/cant-sort-column-in-ant-design-table-in-gatsby-site – B--rian Jan 13 '20 at 11:13

1 Answers1

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
B--rian
  • 5,578
  • 10
  • 38
  • 89