简体   繁体   English

Quickfilter 应该为过滤器列表增加价值

[英]Quickfilter should add value to list of filters

I have a list of custom filters for a basic list in react-admin like this:我在 react-admin 中有一个基本列表的自定义过滤器列表,如下所示:

const ClientListsFilter = (props: FilterProps): JSX.Element => {
  return (
    <Filter {...props}>
      <TextInput label="First Name" source="firstName" resettable />
      <TextInput label="Last Name" source="lastName" resettable />
      <TextInput label="E-Mail" source="email" resettable />
      <QuickFilter label="Has Event Accepted" source="hasEventAccepted" defaultValue={true} />
    </Filter>
  )
}

When I selected now the QuickFilter "Has Event Accepted" it adds the following to the query: hasEventAccepted%22%3Atrue which is to be expected.当我现在选择QuickFilter “Has Event Accepted”时,它会将以下内容添加到查询中: hasEventAccepted%22%3Atrue ,这是可以预料的。

Now, I want to add multiple such "Has Event XYZ" QuickFilters , but instead of having a pair for each in the query it would make sense to just have a list like hasEvents=[1,2,3]现在,我想添加多个这样的“Has Event XYZ” QuickFilters ,而不是在查询中为每个 QuickFilters 设置一对,只需要一个像hasEvents=[1,2,3]这样的列表就有意义了

Is there a way to achieve this in react-admin?有没有办法在 react-admin 中实现这一点? How could I combine multiple values so that a QuickFilter will add directly multiple such events?我如何组合多个值以便QuickFilter将直接添加多个此类事件?

Using the <Filter> component, you can't - it doesn't support your use case.使用<Filter>组件,你不能 - 它不支持你的用例。

So you have 2 options:所以你有两个选择:

  1. Write a custom Filter component that does what you want 编写一个自定义过滤器组件来执行您想要的操作
  2. Name each quick filter in a different way (eg hasEventAccepted , hasEventDeclined , etc.), and convert them to a single hasEvent query parameter in your dataProvider.getList() code.以不同的方式命名每个快速过滤器(例如hasEventAcceptedhasEventDeclined等),并在dataProvider.getList()代码中将它们转换为单个hasEvent查询参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM