GlobalFilter 显示空行
我是反应表的新手,我使用了全局过滤器,但是一旦我在搜索中输入任何内容,所有行都会消失。
GlobalFilter.js
<MDBox width="12rem" ml="auto">
<MDInput
placeholder="Search..."
value={filter || ""}
size="small"
fullWidth
onChange={(e) => {
setFilter(e.target.value);
console.log(filter);
}}
/>
</MDBox>
</>
const tableInstance = useTable(
{ columns, data, initialState: { pageIndex: 0 } },
// useFilters,
useGlobalFilter,
useSortBy,
usePagination
);
const {
getTableProps,
getTableBodyProps,
headerGroups,
prepareRow,
rows,
page,
pageOptions,
canPreviousPage,
canNextPage,
gotoPage,
nextPage,
previousPage,
preGlobalFilteredRows,
setPageSize,
setGlobalFilter,
//state,
// pageIndex,
// pageSize,
state: { pageIndex, pageSize, globalFilter },
} = tableInstance;
//some code
<>
<input
type="text"
value={globalFilter || ""}
onChange={(e) => setGlobalFilter(e.target.value)}
/>
</>
当在搜索中输入某些内容时,所有行都会消失。请帮忙? 全局过滤器正确出现,但过滤后的行未显示
I am new to react table and i used a global filter but as soon as i type anything in search, all the rows disappear..
GlobalFilter.js
<MDBox width="12rem" ml="auto">
<MDInput
placeholder="Search..."
value={filter || ""}
size="small"
fullWidth
onChange={(e) => {
setFilter(e.target.value);
console.log(filter);
}}
/>
</MDBox>
</>
const tableInstance = useTable(
{ columns, data, initialState: { pageIndex: 0 } },
// useFilters,
useGlobalFilter,
useSortBy,
usePagination
);
const {
getTableProps,
getTableBodyProps,
headerGroups,
prepareRow,
rows,
page,
pageOptions,
canPreviousPage,
canNextPage,
gotoPage,
nextPage,
previousPage,
preGlobalFilteredRows,
setPageSize,
setGlobalFilter,
//state,
// pageIndex,
// pageSize,
state: { pageIndex, pageSize, globalFilter },
} = tableInstance;
//some code
<>
<input
type="text"
value={globalFilter || ""}
onChange={(e) => setGlobalFilter(e.target.value)}
/>
</>
All the rows disappear, when something is entered in the search. PLease help?
The global filter is coming correctly but the filtered rows are not being shown
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论