微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何更改tanstack React Table useSelectRow的ID

如何解决如何更改tanstack React Table useSelectRow的ID

嗨,我只是在tanstack React Table上进行构建批量删除的实验 问题是这里我无法更改所选列的ID

为什么要更改此设置?
因为我想要可以发送到服务器的MongoDB ID。
selectedRowIds方法

enter image description here

这里有一些钩子代码

hooks => {
            hooks.visibleColumns.push(columns => [
                // Let's make a column for selection
                {
                    id: 'selection',// accessor: '_id',// The header can use the table's getToggleAllRowsSelectedProps method
                    // to render a checkBox
                    Header: ({ getToggleAllRowsSelectedProps }) => (
                        <div>
                            <IndeterminateCheckBox {...getToggleAllRowsSelectedProps()} />
                        </div>
                    ),// The   cell can use the individual row's getToggleRowSelectedProps method
                    // to the render a checkBox
                    Cell: ({ row }) => {
                        console.log(row)
                        return <div>
                            <IndeterminateCheckBox {...row.getToggleRowSelectedProps()} />
                        </div>

                    },},...columns,])

所有参考文献均来自main documentation

解决方法

使用selectedFlatRows包含所有选定的行数据

enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。