AntdEditableProTable怎么知道某一行的复选框是否被选中或未选中?
创始人
2024-11-07 12:00:09
0

可以通过监听EditableProTable组件的onRow事件和getColumnSearchCheckboxProps方法来获取特定行的复选框状态。具体实现代码如下:

import { EditableProTable } from '@ant-design/pro-table';
import React, { useState } from 'react';

const MyTable = () => {
  const [selectedRowsKeys, setSelectedRowsKeys] = useState([]);

  const columns = [
    {
      title: 'Name',
      dataIndex: 'name',
      copyable: true,
      fieldProps: {
        minLength: 5,
      },
    },
    {
      title: 'Age',
      dataIndex: 'age',
      valueType: 'digit',
    },
    {
      title: 'Address',
      dataIndex: 'address',
    },
    {
      title: 'Action',
      valueType: 'option',
      render: (text, record) => [
        Edit,
        Delete,
      ],
    },
  ];

  const dataSource = [
    {
      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',
    },
  ];

  const rowSelection = {
    selectedRowKeys: selectedRowsKeys,
    onChange: (keys) => {
      setSelectedRowsKeys(keys);
    },
  };

  // get checkbox props
  const getCheckboxProps = (record) => {
    return {
      disabled: record.disabled,
      checked: selectedRowsKeys.includes(record.key),
      // add this prop to provide a way to get checkbox status
      onCheckboxChange: (checked) => {
        console.log(`got checkbox change on ${record.key}, checked: ${checked}`);
      },
    };
  };

  return (
    

相关内容

热门资讯

必备透视!wepoker免费脚... 必备透视!wepoker免费脚本咨询,手机微乐小程序破解器,窍要教程(有挂分析)-哔哩哔哩小薇(辅助...
教你透视!wepoker有插件... 教你透视!wepoker有插件吗,微乐智能辅助软件是真的吗,经验教程(真的有挂)-哔哩哔哩wepok...
开挂透视!wpk透视怎么安装,... 开挂透视!wpk透视怎么安装,微乐自建房辅助下载,步骤教程(有挂讲解)-哔哩哔哩1、玩家可以在wpk...
专业透视!hhpoker透视脚... 专业透视!hhpoker透视脚本,如何下载微乐自建房黑科技入口,机巧教程(有挂分享)-哔哩哔哩1、用...
开挂透视!德州透视是真的假的,... 开挂透视!德州透视是真的假的,微乐小程序挂哪里,手段教程(有挂秘籍)-哔哩哔哩所有人都在同一条线上,...
揭幕透视!hhpoker辅助软... 揭幕透视!hhpoker辅助软件下载,微乐河南麻将辅助ios,项目教程(有挂秘籍)-哔哩哔哩1、让任...
推荐透视!uupoker透视,... 推荐透视!uupoker透视,微乐小程序辅助开发,操作教程(详细教程)-哔哩哔哩1)uupoker透...
总结透视!pokemmo辅助官... 总结透视!pokemmo辅助官网,微信小程序游戏修改器,手筋教程(有挂方法)-哔哩哔哩1)pokem...
揭幕透视!哈糖大菠萝有挂吗,微... 揭幕透视!哈糖大菠萝有挂吗,微信微乐陕西小程序辅助器,方案教程(有挂详情)-哔哩哔哩1、进入游戏-大...
辅助透视!wepoker辅助真... 辅助透视!wepoker辅助真的假的,微信小程序多乐辅助器,方案教程(真的有挂)-哔哩哔哩1、wep...