Jsf Primefaces数据表过滤器,通过显示的值
我正在使用datatable和dynamics列Jsf Primefaces数据表过滤器,通过显示的值,jsf,primefaces,filter,datatable,Jsf,Primefaces,Filter,Datatable,我正在使用datatable和dynamics列,每列上都有一个filterBy。但是我的表中的某些列有一个格式化的值(例如:0和1到db,并显示为“否”和“是”),因此filterBy使用了db值。我使用转换器格式化我的值。 编辑:我使用TMX键以不同的语言显示值。这是我问题的一部分 这是我的HTML <p:dataTable id="employeeBeanPageItems" styl
,每列上都有一个filterBy。但是我的表中的某些列有一个格式化的值(例如:0和1到db,并显示为“否”和“是”),因此filterBy使用了db值。我使用转换器格式化我的值。
编辑:我使用TMX键以不同的语言显示值。这是我问题的一部分
这是我的HTML
<p:dataTable
id="employeeBeanPageItems"
styleClass="table"
value="#{staffListController.model.staffSearch}"
rows="15"
sortBy="#{_item.stfFullName}"
var="_item"
draggableColumns="true"
widgetVar="itemsTable"
selectionMode="single"
rowKey="#{_item.stfId}"
resizableColumns="true"
scrollable="false"
tableStyle="width:auto"
emptyMessage="#{msg['error.no-result']}"
paginator="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="10,15,20,50">
<p:ajax event="rowSelect" listener="#{staffListController.onRowSelect}" />
<p:ajax event="colReorder" listener="#{staffListController.onColumnReorder}" update=":search:menuColonne"/>
<p:columns filterMatchMode="contains" headerText="#{msg[column.header]}" value="#{staffListController.columns}" var="column" columnIndexVar="colIndex" sortBy="#{_item[column.property]}" filterBy="#{_item[column.property]}">
<h:outputText value="#{_item[column.property]}" converter="StaffListConverter"/>
</p:columns>
</p:dataTable>
也许我应该用一种不同的方式来格式化我的数据,但我不知道如何格式化。目的是让过滤器通过使用
加:
我在模型中使用以下代码尝试了第一条注释给出的解决方案
public String getStfResourceLaptopFormat() {
if (stfResourceLaptop != null)
{
if (stfResourceLaptop.equals("1"))
{
return "common.yes";
}
else if(stfResourceLaptop.equals("0"))
{
return "common.no";
}
else return null;
}
else
{
return null;
}
}
问题是我必须返回TMK密钥,然后过滤器才能使用该密钥:/
<p:columns filterMatchMode="contains" headerText="#{msg[column.header]}" value="#{staffListController.columns}" var="column" columnIndexVar="colIndex" sortBy="#{_item[column.property]}" filterBy="#{_item[column.property]}">
<h:outputText value="#{msg[_item[column.property]]}" />
</p:columns>
转换器仅转换显示值getAsString
方法不会更改对象。因此,您必须在创建staffListController.model.staffSearch
列表时更改该值。当您从DB change中提取值时,它本身在列表中,转换器仅转换显示的值getAsString
方法不会更改对象。因此,您必须在创建staffListController.model.staffSearch
列表时更改该值。当您从DB获取值时,请在列表中更改它本身谢谢您的回答。是的,你说得对。我使用下面的示例公共字符串getStfResourceLaptopFormat(){if(stfResourceLaptop!=null){if(stfResourceLaptop.equals(“1”){return”common.yes;}else if(stfResourceLaptop.equals(“0”){return”common.no;}else返回null;}else{return null;}}问题是我必须返回一个TMX键,然后用TMX键附加搜索。谢谢你的回答。是的,你是对的。我用下面的示例公共字符串getStfResourceLaptopFormat()尝试了类似的方法{if(stfResourceLaptop!=null){if(stfResourceLaptop.equals)(“1”){return“common.yes”;}else if(stfResourceLaptop.equals(“0”){return“common.no”;}else返回null;}else{return null;}问题是我必须返回一个TMX键,然后用TMX键追加搜索
<p:columns filterMatchMode="contains" headerText="#{msg[column.header]}" value="#{staffListController.columns}" var="column" columnIndexVar="colIndex" sortBy="#{_item[column.property]}" filterBy="#{_item[column.property]}">
<h:outputText value="#{msg[_item[column.property]]}" />
</p:columns>