简体   繁体   English

复选框在 react-bootstrap-table-next 中不起作用

[英]check boxes are not functioning in react-bootstrap-table-next

I am using react-bootstrap-table2 , to make tables, I have encounter an issue ie我正在使用react-bootstrap-table2来制作表格,我遇到了一个问题,即

I want o have a checkbox inside my table, so I am following This, mention in the documentation , but I am getting unexpected result.我希望在我的表中有一个复选框,所以我正在关注这个,在文档中提到,但我得到了意想不到的结果。

My code我的代码

For selecting the row用于选择行

const selectRow = {
    mode: 'checkbox',
    clickToSelect: true,
    classes: 'selection-row',
};

Table rendering表格渲染

  <BootstrapTable
    keyField="id"
    data={tableData[0].rowsData}
    columns={tableData[0].columnsData}
    selectRow={selectRow}
 />

I Think issue is coming because of my data, as it is nested one And I am rendering it, but I am not able to resolve it.我认为问题是由于我的数据而出现的,因为它是嵌套的并且我正在渲染它,但我无法解决它。

My data我的资料

let tableData = [
{
  rowsData: [
    {
      fname: "john",
      lname: "smith"
    },
    {
      fname: "steve",
      lname: "warn"
    },
    {
      fname: "michel",
      lname: "clark"
    }
  ],
  columnsData: [
    {
      dataField: "fname",
      text: "First name",
      sort: true
    },
    {
      dataField: "lname",
      text: "last Name",
      sort: true
    }
  ]
}

]; ];

Here is my code sandbox link This这里是我的代码沙箱链接

You're telling keyField="id" yet each of your rowsData has no id .您告诉keyField="id"但您的每个rowsData都没有id Give each of them an id and it should work.给他们每个人一个id ,它应该可以工作。

编辑圣羽-s0upd

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 React-Bootstrap-Table-Next 对动态表上的字母数字字符串进行排序 - React-Bootstrap-Table-Next Sort Alphanumeric Strings on Dynamic Table 从 react-bootstrap-table-next 路由到新组件? - Routing to a new component from react-bootstrap-table-next? 如何控制 react-bootstrap-table-next 中的 boolean 字段 - How to Control boolean field in react-bootstrap-table-next React-Bootstrap-Table-Next Search Bar onSearch 不是一个函数 - React-Bootstrap-Table-Next Search Bar onSearch is not a function 如何在 react-bootstrap-table-next 表的列中显示倒计时? - How do I display countdowns in a column of a react-bootstrap-table-next table? 使用 react-bootstrap-table-next 时如何删除表的 header - how to remove the header of the table when using react-bootstrap-table-next 未捕获的错误:使用 react-bootstrap-table-next 时,对象作为 React 子项无效 - Uncaught Error: Objects are not valid as a React child while using react-bootstrap-table-next 带有 mobx 商店的 react-bootstrap-table-next 不呈现更改 - react-bootstrap-table-next with mobx store doesn't render changes 在表格中添加复选框 - Add check boxes to table 下一页和上一页在 react-bootstrap-table2-paginator 中不起作用 - next page and previous page not working in react-bootstrap-table2-paginator
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM