React+antd

1, clipboard.png
2
clipboard.png
3 how to use antd table components in react development to click on the child row to get the data of the parent row

Mar.31,2022

there is a method for onExpand to listen for opening subtable events. The parameter contains the current record, and you can maintain a current open subtable item in state. But in this case, it will be a problem if you can open more than one at the same time. I don't know which one you are operating. Another approach that I can think of is to associate the child table with the data of the parent table at the DataSource level. For example:

const ParentData = [
    {id: 1, name: 'demo', age: 20},
    {id: 2, name: 'smile', age: 30}
];

const childData = [
    [
        {
            parentId: 1,
            name: 'demo_friend1'
        },
        {
            parentId: 1,
            name: 'demo_friend2'
        }
    ],
     [
        {
            parentId: 2,
            name: 'smile_friend1'
        },
        {
            parentId: 2,
            name: 'smiel_friend2'
        }
    ]
]

this makes it easy to operate.
that's all I can think of right now!

Menu