reactjs - react-bootstrap-table-next 搜索不起作用
问题描述
我最近开始使用 react-bootstrap-table-next 组件。我无法让搜索工作。
这是我安装的:
react-bootstrap-table-next 4.0.3
react-bootstrap-table2-paginator 2.1.2
react-bootstrap-table2-toolkit 2.1.3
这是我的代码:
import BootstrapTable from 'react-bootstrap-table-next';
import 'react-bootstrap-table-next/dist/react-bootstrap-table2.min.css';
import paginationFactory from 'react-bootstrap-table2-paginator';
import ToolkitProvider, { Search } from 'react-bootstrap-table2-toolkit';
actionFormat(cell, row, rowIndex) {
return (<div><span className='fa fa-pencil-square-o' onClick={() => this.props.parentEdit(cell, row, rowIndex)} data-id={cell} title='Edit'></span>
<span className='fa fa-trash-o' data-id={cell} onClick={() => this.props.parentDelete(cell, row, rowIndex)} title='Delete'></span></div>)
}
render() {
if (this.props.isAccount) {
cols = [{ text: 'Actions', dataField: 'Actions', formatter: this.actionFormat.bind(this) },
{ text: 'Id', dataField: 'Id', sort: true },
{ text: 'Name', dataField: 'Name', sort: true },
{ text: 'User Name', dataField: 'UserName', sort: true },
{ text: 'Created', dataField: 'DateCreatedView', sort: true },
{ text: 'Email Confirmed', dataField: 'EmailConfirmed', sort: true },
]
}
const { SearchBar } = Search;
return (
<Container fluid>
<ToolkitProvider
keyField="Id"
data={this.state.data}
columns={cols}
search
bootstrap4
>
{
props => (
<div>
Search:
<SearchBar {...props.searchProps} />
<BootstrapTable bootstrap4 pagination={paginationFactory(pagingOptions)} width='100vw;'
striped condensed {...props.baseProps}>
</BootstrapTable>
</div>
)
}
</ToolkitProvider>
);
}
引用 ToolkitProvider 中的基本道具,而不是在 BootstrapTable 元素中设置数据和列元素
解决方案
推荐阅读
- php - 使用 PHP 计算 PDF 中的页数
- r - 在闪亮的 R 中的下载处理程序中使用 promise 对象
- python - argparse 多个可选参数
- php - 使用ajax在Php中以“电子邮件已存在”条件提交表单
- mysql - 将'b'文字放在非位值之前时如何处理MySQL WorkBench位(1)错误?
- javascript - request.js 回调不遵循脚本顺序
- reactjs - Preact 路由器:同一个组件的多个路径名
- c# - 需要提取二维数组 (256x256) 中的所有单元格,这些单元格落在以原点为中心的扇区中,并将所有其他单元格标记为零
- angular - 在带有父子路由的反应式表单中使用 patchValue
- dbus - dbus-1.0/dbus/dbus.h:29:10:致命错误:找不到“dbus/dbus-arch-deps.h”文件