gpt4 book ai didi

java - Tabview 中的 Primefaces 数据表 - 第二个选项卡上的初始排序不起作用

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:09:06 27 4
gpt4 key购买 nike

我有一个 tabView,其中每个选项卡都包含一个数据表。我是这样设置的

<p:tabView id="tabView" styleClass="manage-tab-view" prependId="false" 
activeIndex="#{managementTabBean.activeIndex}" dynamic="true" cache="false">
<p:tab id="users" title="#{msg['TeamManagement.Tabs.Users']}" >
<ui:include src="tab1.xhtml" />
</p:tab>
<p:tab id="athletes" title="#{msg['TeamManagement.Tabs.Athletes']}">
<ui:include src="tab2.xhtml" />
</p:tab>
</p:tabView>

在每个选项卡中,我试图显示一个数据表。现在我把它设置成这样:

标签 1:

<h:form id="userProfileViewForm" prependId="false">
<p:dataTable var="userProfile" value="#{userProfileListBean.objects}"
id="userProfilesTable" sortBy = "#{userProfile.lastName}" sortFunction = "#{userProfileListBean.sortUserLastName}" sortOrder = "ascending" lazy="true">

<p:column sortBy="#{userProfile.lastName}" sortFunction = "#{userProfileListBean.sortUserLastName}" id="userName">
p:commandLink>
<p:commandLink rendered="#{!appContextBean.isCWContext()}"
onclick="window.location.href='userBS.xhtml?id=#{userProfile.id}'">
<div class="clickable-cell">
<h:outputText
value="#{userProfile.firstName} #{userProfile.lastName}" />
</div>
</p:commandLink>
</p:column>

...more columns...

Tab2:相似数据表

<p:dataTable var="athlete" value="#{athleteListBean.objects}"
tableStyle="width:auto" sortBy="#{athlete.getDisplayName()}" sortFunction = "#{athleteListBean.sortAthleteDisplayName}" id="athletesTable"
sortOrder="#{athleteListBean.getListSortOrderDesc()}" lazy="true" paginator="true" rows="15" paginatorPosition="bottom"
paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}">

<p:column sortBy="#{athlete.getDisplayName()}" sortFunction = "#{athleteListBean.sortAthleteDisplayName}" id="athleteColumn">
<h:outputText styleClass="athlete-listing athlete-name" value="#{athlete.firstInitial} #{athlete.lastName}" />
</p:column>

如您所见,我为两个数据表设置了自定义初始排序函数。

由于某种原因,第一个选项卡排序函数被调用,而第二个选项卡排序函数没有。在我交换选项卡 View 中的选项卡后,tab2 排序函数被调用,但 tab1 没有。

基本上仅在第一个选项卡的数据表上调用初始排序函数,基于选项卡 View 中选项卡的顺序。谁能告诉我为什么会这样?

感谢您的帮助。

最佳答案

我有一个类似的问题,在我的例子中,第二个选项卡上有一个 p:dataTable 和 p:columnToggler,点击按钮隐藏或显示列显示为黑色,无法删除列。

我找到的解决方案是在 p:TabView 中的 p:ajax 中添加事件“tabChange”

这样问题就解决了,我已经在 p:columnToggler 上正常工作了。

也许您解决了 p:dataTable 的顺序问题。

这里是我的代码:

<p:tabView effect="fade" effectDuration="fast"  prependId="false">
<p:ajax event="tabChange" update="@this"/>
<p:tab title="#{text['liquidacionForm.tabDatosLiq']}">
<ui:include src="/datosLiquidacion.xhtml"></ui:include>
</p:tab>
<p:tab title="#{text['liquidacionForm.tabEstanciasLiq']}">
<ui:include src="/estanciasLiquidadas.xhtml"></ui:include>
</p:tab>
</p:tabView>

关于java - Tabview 中的 Primefaces 数据表 - 第二个选项卡上的初始排序不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16700845/

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