【发布时间】:2015-04-25 00:50:19
【问题描述】:
我尝试使用 Primefaces 4 获得一个 totalRecords 编号(在过滤和不过滤时计算行号)。
我的总记录数的分页器输出正在工作,直到我尝试过滤数据表:
<p:dataTable id="tbl_queue" var="c" value="#{productionQueue.cartQueue}" widgetVar="queueTable"
filteredValue="#{productionQueue.filteredCartQueue}" paginator="true"
currentPageReportTemplate="Nb rows: {totalRecords}"
paginatorTemplate="{CurrentPageReport}">
<p:column id="Bumper_column" filterBy="name_bumper" headerText="Bumper"
filterOptions="#{productionQueue.nameBumperOptionsString}"
filterMatchMode="exact"
styleClass="#{productionQueue.determineRowColor(c.date,c.hour)}">
<h:outputText value="#{c.name_bumper}" />
</p:column>
...
</p:datatable>
每次更新后,totalRecords 输出显示值:“未定义”
编辑(与 PF Showcase 示例相同的问题):
但我必须更改一些内容才能运行示例...:
还有……:
因为当我尝试对 Showcase 中的示例进行任何更改时,我遇到了这个错误:
所以最后我认为过滤器 Nb Rows 由于 Bean 的类型(SessionScoped)而无法正常工作,我被它阻止了,因为我需要在此页面中使用 SessionScoped 来管理我的数据表......
【问题讨论】:
-
浏览器控制台有错误吗?
-
不,我在 Chrome 控制台中没有任何 javascript 错误。
-
PrimeFaces 4.0 的文档显示了类似你的语法(filterBy="name_bumper")。但是在 PrimeFaces 5.0 中,它就像在 3.4.2(filterBy="#{c.name_bumper}") 中一样。对于测试,您可以只保留列并暂时取出其余的过滤器选项以隔离问题。我现在无法测试您的代码。请查看 PrimeFaces 5.0 的 filterBy 语法是否有所不同。
-
如果我喜欢 PF5.0 或 3.4.2 (filterBy="#{c.name_bumper}"),我已经有了 : "undefined" 值,我的过滤器现在不工作了。 ..所以这绝对不是解决方案^^.
-
您可以从 PrimeFaces 展示中获取分页和过滤示例的代码并将它们组合起来,看看是否还有问题。你能把代码贴在你做过滤的地方吗?
标签: primefaces datatable pagination filtering