getCheckboxProps的使用

官方给的解释是:选择框的默认属性配置
官方要求的参数是一个方法

看一个官方示例:

getCheckboxProps: (record: DataType) => {
      console.log("getCheckboxProps",record)
      return {
      disabled: record.name === 'Disabled User', // Column configuration not to be checked
      name: record.name,
    }},

我们这里的console.log出来可以看到就是记录的当前表格的每一行的数据
再结合一下示例,就能知道,这几行代码的意思就是,每一行checkBox的name参数与表格中对应行数据的name参数一致,且当表格中对应行数据的name为'Disabled User'时,checkbox设为不可用

所以总结来说,是为了配置CheckBox的默认属性
这句话描述的非常准确,只是我们可能看不太懂而已

需求

写一个表格,表格中的条目,当其属性disable为true的时候,checkbox也给它禁用掉,请问怎么做?

方案
const rowSelection = {
    getCheckboxProps: (record: DataType) => {
      return {
      disabled: record.disable, // Column configuration not to be checked
      name: record.name,
    }},
  };
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容