【发布时间】:2021-01-20 15:26:39
【问题描述】:
我对反应完全陌生。 这可能微不足道,但我不知道如何实现清除所有表格过滤器的操作。
在我的表格中,我使用日期过滤器、下拉列表、文本和全局过滤器寻找一键清除所有过滤器
https://codesandbox.io/s/eager-thunder-ejlg5?file=/src/index.js
<MaterialTable
title="Free Action Preview"
columns={[
{ title: "Name", field: "name" },
{ title: "Surname", field: "surname" },
{ title: "Birth Year", field: "birthYear", type: "numeric" },
{
title: "Birth Place",
field: "birthCity",
lookup: { 34: "İstanbul", 63: "Şanlıurfa" }
}
]}
data={[
{ name: "Mehmet", surname: "Baran", birthYear: 1987, birthCity: 63 },
{
name: "Zerya Betül",
surname: "Baran",
birthYear: 2017,
birthCity: 34
}
]}
actions={[
{
icon: () => <FilterNoneIcon />,
tooltip: "clear all filters",
isFreeAction: true,
onClick: (event) => alert("clear all filters logic")
}
]}
options={{
filtering: true,
sorting: true
}}
/>
【问题讨论】:
-
请阅读 stackoverflow.com/help/minimal-reproducible-example 提供一些重现问题的最小代码,以便观众更好地理解。
-
@Prasad Phule 添加了一个示例项目,我确实知道 StackOverflow 的角色非常好!.. 这是一个非常强大的前瞻性问题
标签: reactjs material-ui material-table