1

我正在为 React 实现 Ant 设计库上的可扩展表格行功能,它显示得非常好,但没有生成展开按钮(加号)。我还没有找到解决方案,我尝试生成/显示展开(加号)按钮。请帮我。下面是完整的代码:

import React from 'react';
import { useSelector} from 'react-redux';
import 'antd/dist/antd.css';
import ReactDOM from 'react-dom';
import { Table } from 'antd';
import { Tag} from 'antd';
// import "./index.css";
import {selectRequesting} from "../../../selectors/requesting/RequestingSelector";
import BankAction from "../../../stores/bank/BankAction";
import TableComponent from "../TableComponent";
import {_makeSelectBranchTableData} from "../../../stores/bank/BankSelector";


export default function TableNIDAndProfileVerification (){

    const tableData = useSelector(state => _makeSelectBranchTableData(state));
    const isRequesting= useSelector(state => selectRequesting(state, [BankAction.REQUEST_ALL_BRANCHES_OF_DISTRICT]));

const details =  <h1>Title <span>plus</span></h1>
    const columns = [
        { title: 'Name', dataIndex: 'name', key: 'name' },
        { title: 'Age', dataIndex: 'age', key: 'age' },
        { title: 'Address', dataIndex: 'address', key: 'address' },
        {
            title: 'Action', dataIndex: '', key: 'x', render: () => <a>Delete</a>,
        },
    ];

    const data = [
        {
            key: 1, name: 'John Brown', age: 32, address: details, description: details,
        },
        {
            key: 2, name: 'Jim Green', age: 42, address: 'London No. 1 Lake Park', description: 'My name is Jim Green, I am 42 years old, living in London No. 1 Lake Park.',
        },
        {
            key: 3, name: 'Not Expandable', age: 29, address: 'Jiangsu No. 1 Lake Park', description: 'This not expandable',
        },
        {
            key: 4, name: 'Joe Black', age: 32, address: 'Sidney No. 1 Lake Park', description: 'My name is Joe Black, I am 32 years old, living in Sidney No. 1 Lake Park.',
        },

    ];

    return (
        <>
    <Table
        columns={columns}
        expandable={{
            expandedRowRender: record => <p style={{ margin: 0 }}>{record.description}</p>,
            rowExpandable: record => record.name !== 'Not Expandable',
        }}
        dataSource={data}
        />,
    </>
    );


}
4

0 回答 0