Reactjs 根据react表中的条件禁用某些行

Reactjs 根据react表中的条件禁用某些行,reactjs,react-table,Reactjs,React Table,我需要根据特定条件禁用某些行。这是我的代码: <ReactTable data={this.state.categoryTable} loading={this.state.loading} noDataText="Please select a country template" columns={[ { Header: 'Category/Lot', accessor: 'category_name' }, {

我需要根据特定条件禁用某些行。这是我的代码:

<ReactTable    
  data={this.state.categoryTable}
  loading={this.state.loading}
  noDataText="Please select a country template"
  columns={[
    {
      Header: 'Category/Lot',
      accessor: 'category_name'
    }, {
      Header: "Display Name",
      accessor: "display_name",
      Cell: this.renderEditable
    }, {
      Header: 'Price(per month)',
      accessor: 'price',
      Cell: this.renderEditable
    }, {
      Header: 'Spots',
      accessor: 'spots',
      Cell: this.renderEditable
    }>


当类别/批次等于“南美洲”时,我需要禁用价格和现货行。

我发现为了访问当前行中的另一个字段,您应该访问
行。行

因此,您的代码应该是这样编写的:

<ReactTable    
  data={this.state.categoryTable}
  loading={this.state.loading}
  noDataText="Please select a country template"
  columns={[
    {
      Header: 'Category/Lot',
      accessor: 'category_name'
    }, {
      Header: "Display Name",
      accessor: "display_name"
    }, {
      Header: 'Price(per month)',
      accessor: 'price',
      Cell: row => row.row.category_name=="South America" ? ***disable*** : row.value
    }, {
      Header: 'Spots',
      accessor: 'spots',
      Cell: row => row.row.category_name=="South America" ? ***disable*** : row.value
    }]}
 />
row.row.category\u name==“南美”***禁用***:row.value
}, {
标题:“斑点”,
访问者:'点',
单元格:行=>row.row.category_name==“南美”?***禁用***:row.value
}]}
/>
现在,我不确定你说的禁用一行是什么意思。。但您可以在表或类似的解决方案中处理具有“禁用”索引集合的状态

或者,如果要在单元格内渲染其他组件,则可以将“禁用”传递给某些属性:

Cell: row => (<SomeSubComponent disable={row.row.category_name=="South America"} value={row.value} />)
单元格:行=>()

希望我能帮上忙:)

禁用一行是什么意思?看起来你的
数组缺少了一个结束符
]
,之后又缺少了一个结束符
}
,结束了
属性