reactjs - 如何更改 tanstack React Table useSelectRow 的 id
问题描述
嗨,伙计,我只是在 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,
])
并且所有完整参考都来自主要文档
解决方案
推荐阅读
- vector - 检查 Vec
看看它是否全为零? - python - 在 Python 中,是否有一个 python 标准函数可以像 bash 一样将字符串解析为 argv 列表?
- python - 将 tf.nn.dropout() 与 3D-CNN 一起应用的问题
- javascript - 如何在我的角度项目中添加气候时钟小部件
- node.js - 具有联合类型的 ajv 数组
- node.js - 如何在 React 中有条件地渲染我的组件?根据我的问题,我不知道这是否是一个合适的标题
- r - 将分层json解析为R中的表
- javascript - 两个数组的 Firebase Firestore 查询
- c++ - back_inserter如何判断容器的类型
- cassandra - 连接到 Cassandra 时连接被拒绝