Search code examples
reactjsantd

Ant table problem using both expandable and rowSelection


I want row selection checkbox to come first, if I use both expandable and rowSelection

But I am getting expandable as first column.

 <Table
  className='assignment-table'
  columns={columns}
  dataSource={data}
  pagination={false}
  expandable={{ expandedRowRender }}
  rowSelection={
    props.onSelectionChange && {
      selectedRowKeys: props.selectedRows,
      onChange: props.onSelectionChange,
    }
  }
/>

How can we change row selection should come first here: https://codesandbox.io/p/sandbox/dynamic-settings-antd-5-12-7-hgz4r7?file=%2Fdemo.tsx


Solution

  • We can solve this passing first two columns as below

       const columns = [
           Table.SELECTION_COLUMN,
           Table.EXPAND_COLUMN, ...]