gpt4 book ai didi

全局过滤器的 JSF Primefaces 数据表匹配模式(不是单个列)

转载 作者:行者123 更新时间:2023-12-01 02:20:36 24 4
gpt4 key购买 nike

global filter的过滤器匹配模式是什么? (不是默认为“startsWith”的单个列过滤器)以及如何更改它?

我问的原因是,当我在所有列中使用匹配模式设置为“startsWith”的全局过滤器时,我仍然使用“包含”过滤器模式获得值。请参阅下面的屏幕截图。

country table screenshot

我不应该得到除第一行以外的行,因为我在所有列中都指定了“startsWith”。

这是我的数据表,

<h:form id="countryTable">
<p:dataTable rowKey="" value="#{countryBean.countriesList}"
var="country" selection="#{countryBean.selectedCountries}"
styleClass="data-table-style" widgetVar="countryTableWVar"
filteredValue="#{countryBean.filteredCountries}">
<f:facet name="header">
<div class="align-left">
<p:outputPanel>
<h:outputText value="Search all fields:" />
<p:inputText id="globalFilter" onkeyup="countryTableWVar.filter();"
style="width:150px" />
</p:outputPanel>
</div>

</f:facet>
<p:column selectionMode="multiple" style="width:2%;" />
<p:column headerText="Numeric Code" filterMatchMode="startsWith"
filterStyle="display:none" filterBy="numericCode">
<h:outputText value="#{country.numericCode}"></h:outputText>
</p:column>
<p:column headerText="Alpha_2 Code" filterMatchMode="startsWith"
filterStyle="display:none" filterBy="alpha2">
<h:outputText value="#{country.alpha2}"></h:outputText>
</p:column>
<p:column headerText="Alpha_3 Code" filterMatchMode="startsWith"
filterStyle="display:none" filterBy="alpha3">
<h:outputText value="#{country.alpha3}"></h:outputText>
</p:column>
<p:column headerText="Name" filterMatchMode="startsWith"
filterStyle="display:none" filterBy="name">
<h:outputText value="#{country.name}"></h:outputText>
</p:column>
</p:dataTable>
</h:form>

如何更改数据表全局过滤器匹配模式?

最佳答案

如果你看primefaces的源代码

org.primefaces.component.datatable.feature.FilterFeature.java

在第 133 行,您可以看到 primefaces 使用 contains String的方法

if(columnValue.toLowerCase(filterLocale).contains(globalFilter)){
globalMatch = true;
}

因此,目前除了根据您的需要更改代码并构建您自己的 primefaces jar 之外别无他法。

关于全局过滤器的 JSF Primefaces 数据表匹配模式(不是单个列),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20800716/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com