我想修改搜索react-bootstrap-table
multiColumnSearch
以要求来自两列或多列的数据,而不是匹配表中的所有数据。
例子:
ID FAMILY YEAR
---------------------
1 FAMILY-1 2010
2 FAMILY-1 2011
3 FAMILY-2 2010
4 FAMILY-2 2011
询问:FAMILY-1 2010
当前结果:
ID FAMILY YEAR
---------------------
1 FAMILY-1 2010
2 FAMILY-1 2011
3 FAMILY-2 2010
期望的结果:
ID FAMILY YEAR
---------------------
1 FAMILY-1 2010
当前代码:
options: Options = {
defaultSortName: 'Id',
defaultSortOrder: 'desc',
noDataText: 'Empty data',
onRowClick: this.onRowClick.bind(this)
};
render() {
return (
<div>
<BootstrapTable containerStyle={{ marginTop: '10px' }} data={this.state.tableCases} options={this.options} striped={true} hover={true} search multiColumnSearch>
<TableHeaderColumn dataField='Id' isKey={true} dataSort={true}>Case ID</TableHeaderColumn>
<TableHeaderColumn dataField='CompanyName' dataSort={true}>Company Name</TableHeaderColumn>
<TableHeaderColumn dataField='Title' dataSort={true}>Title</TableHeaderColumn>
<TableHeaderColumn dataField='Family' dataSort={true}>Family</TableHeaderColumn>
<TableHeaderColumn dataField='ApplicationDate' dataSort={true}>Application Date</TableHeaderColumn>
</BootstrapTable>
</div>
);
}
https://allenfang.github.io/react-bootstrap-table/docs.html#multiColumnSearch
更新:
感谢@FiriceNguyen,我能够解决它。添加了对 distinctlyTyped 的拉取请求,strictSearch
以便其他人将来可以使用它。代码:
<div>
<BootstrapTable containerStyle={{ marginTop: '10px' }} data={this.state.tableCases} options={this.options} striped={true} hover={true} search multiColumnSearch strictSearch>
<TableHeaderColumn dataField='Id' isKey={true} dataSort={true}>Case ID</TableHeaderColumn>
<TableHeaderColumn dataField='CompanyName' dataSort={true}>Company Name</TableHeaderColumn>
<TableHeaderColumn dataField='Title' dataSort={true}>Title</TableHeaderColumn>
<TableHeaderColumn dataField='Family' dataSort={true}>Family</TableHeaderColumn>
<TableHeaderColumn dataField='ApplicationDate' dataSort={true}>Application Date</TableHeaderColumn>
</BootstrapTable>
</div>
https://github.com/DefinitelyTyped/DefinitelyTyped/pull/19629