FullTextFilter 全文搜索过滤器

This component requires the free Search add-on.

FullTextFilter 组件在功能上与 propertyFilter 属性过滤器 组件类似,但是在所有实体字段索引中进行全文搜索。

XML 元素

fullTextFilter

Java 类

io.jmix.searchflowui.component.FullTextFilter

基本用法

在视图 XML 中声明 search 命名空间:

<view xmlns="http://jmix.io/schema/flowui/view"
      xmlns:search="http://jmix.io/schema/search/ui"
      title="msg://searchView.title">

当使用顶部操作面板中的 Add Component 操作添加组件时,Studio 会自动添加该命名空间。请参见 组件面板。

通过 dataLoader 属性将 fullTextFilter 与集合数据加载器进行绑定。下面的示例中,声明了数据、过滤器和结果表格:

<data>
    <collection id="ordersDc"
                class="com.company.demo.entity.Order">
        <loader id="ordersDl"
                readOnly="true">
            <query>
                <![CDATA[select e from Order_ e]]>
            </query>
        </loader>
        <fetchPlan extends="_base">
            <property name="customer"
                      fetchPlan="_base"/>
        </fetchPlan>
    </collection>
</data>
<facets>
    <dataLoadCoordinator auto="true"/>
</facets>
<layout>
    <search:fullTextFilter dataLoader="ordersDl"
                           autoApply="true"/>
    <dataGrid id="ordersDataGrid"
              width="100%"
              dataContainer="ordersDc">
        <columns>
            <column property="number"/>
            <column property="date"/>
            <column property="amount"/>
            <column property="product"/>
            <column property="customer"/>
        </columns>
    </dataGrid>
</layout>

FullTextFilter 组件的操作方式如下:

  1. 执行全文搜索以查找与搜索条件匹配的实体标识符。

  2. 将包含这些标识符的条件附加到关联的 dataLoader 上。

  3. 当 DataGrid(或其他列表组件)与此数据加载器关联时,仅显示与全文搜索条件匹配的那些记录。

全文条件还可以与数据加载器的其他过滤器结合使用,提供更精细的结果集。

验证

如需检查 fullTextFilter 组件输入的值,可以在内部元素 validators 中添加一个 validator。

fullTextFilter 可以使用下列预定义的验证器:

XML 元素

validators

预定义验证器

custom - decimalMax - decimalMin - digits - doubleMax - doubleMin - email - future - futureOrPresent - max - min - negative - negativeOrZero - notBlank - notEmpty - notNull - past - pastOrPresent - positive - positiveOrZero - regexp - size

XML 属性

下面是 fullTextFilter 的特殊属性:

名称 描述 默认值

autoApply

设置为 true 时,FullTextFilter 组件在值变化时自动应用到关联的 DataLoader。

jmix.ui.component.filter-auto-apply

dataLoader

必需属性。设置当前 fullTextFilter 关联的 数据加载器。该加载器必须是一个集合加载器。

-

labelPosition

Sets the position of the label relative to the filter value component. See propertyFilter label position.

—

labelWidth

Sets the label width as a CSS length. See propertyFilter label width.

—

searchStrategy

设置搜索策略。参考 搜索策略。

jmix.search.default-search-strategy

下面是 fullTextFilter 支持的其他通用属性:

事件和处理器

下面是 fullTextFilter 的特殊事件和处理器:

名称 描述

validator

验证组件值。

下面是 fullTextFilter 支持的其他通用事件:

XML 内部元素

一个 fullTextFilter 可以包含 tooltip 和 validator 作为其内部元素。