嗨,伙计,我只是在 tanstack React Table 上进行构建批量删除实验,问题出在这里我无法更改所选列的 id
我为什么要改变这个?
因为我想要可以发送到服务器的 MongoDB id。
用selectedRowIds
方法
这里有一些来自钩子的代码
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,
])
并且所有完整参考都来自主要文档