关于Table默认勾选框问题 antd

项目模块用antd的Table做了个表格,现在遇到个问题,发现Table API里面没有默认勾选的方法,找了半天没找到,有做过类似的麻烦解答下哈,谢谢

下面是Table demo

const { Table } = antd;
const columns = [{
  title: 'Name',
  dataIndex: 'name',
  render: text => <a href="#">{text}</a>,
}, {
  title: 'Age',
  dataIndex: 'age',
}, {
  title: 'Address',
  dataIndex: 'address',
}];
const data = [{
  key: '1',
  name: 'John Brown',
  age: 32,
  address: 'New York No. 1 Lake Park',
}, {
  key: '2',
  name: 'Jim Green',
  age: 42,
  address: 'London No. 1 Lake Park',
}, {
  key: '3',
  name: 'Joe Black',
  age: 32,
  address: 'Sidney No. 1 Lake Park',
}, {
  key: '4',
  name: 'Disabled User',
  age: 99,
  address: 'Sidney No. 1 Lake Park',
}];
const rowSelection = {
  onChange: (selectedRowKeys, selectedRows) => {
    console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
  }
};

ReactDOM.render(
  <Table scroll={{ x: true, y: 200 }} pagination={false} rowSelection={rowSelection} columns={columns} dataSource={data} />
, mountNode);

图片描述

图片描述

阅读 8.5k
3 个回答

clipboard.png
好好看文档不好么

新手上路,请多包涵

getCheckboxProps: record => ({

    disabled: this.props.editStatue,
    checked: (this.props.selectedRowKeys.indexOf(record.Id)>-1?true:false),
  }),

clipboard.png

好像也不行

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题