首页 > 解决方案 > Primefaces 的扩展数据表共享相同的分页状态?

问题描述

Primefaces 的扩展数据表共享相同的分页状态?我正在研究primefaces7。我有一个 primefaces 数据表,其行将扩展以加载子表数据,但我发现子故事共享相同的分页状态。

步骤如下:

  1. 在代码中,将子表每页的行数全部设置为3,然后启动应用程序。
  2. 点击主表第一行,加载第一个子表的数据,每页加载3行数据。
  3. 将第一个子表的行数从3改为6,第一个子表将加载每页6行的数据。
  4. 单击主表上的第二行,第二个子表仍然加载,每页 6 行,但是,正确的行为应该是每页 3 行。
  5. 将第二个子表的行数从 6 更改为 3。
  6. 折叠主表的第一行,然后再次展开,现在第一个子表在每页加载 3 行,这与预期的结果不同,它应该在每页加载 6 行数据。

提供以下两个图像以提供更清晰的信息。 https://note.youdao.com/yws/public/resource/944651b2b0a5f1fd15ba638f29761212/xmlnote/BF343E65325749A1A1AC1A4CC2BA4176/3832

https://note.youdao.com/yws/public/resource/944651b2b0a5f1fd15ba638f29761212/xmlnote/1D7E179E340442B48EC813DF2BBAF63A/3834

这是代码。

<p:dataTable var="hosp"
                 binding = "#{hospitalController.hospitalTable}"
                 value="#{hospitalController.hospData}"
                 paginator="true"
                 rows="10"
                 paginatorPosition="bottom"
                 paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
                 currentPageReportTemplate="{currentPage} of {totalPages} pages, {totalRecords} records"
                 rowsPerPageTemplate="5,10,15"
                 lazy="true"
                 id="hospitalTable"
                 widgetVar="hospitalTable"
                 >
        <p:ajax event="rowToggle" listener="#{hospitalController.doToggle(hosp.hospitalId)}"/>
        <f:facet name="header">
            <h:outputText value="Hospital List" />

        </f:facet>

        <p:column style="width:16px">
             <p:rowToggler></p:rowToggler>
        </p:column>

        <p:column headerText="Hospital Code">
            <h:outputText value="#{hosp.hospitalId}" />
        </p:column>

        <p:column headerText="Hospital Name">
            <h:outputText value="#{hosp.hospitalName}" />
        </p:column>


        <p:rowExpansion>
                <p:panelGrid columnClasses="label, value">
                    <p:dataTable value="#{hospitalController.subHospData}"
                                 var="subHosp"
                                 id="subHospTable"
                                 paginator="true"
                                 rows="3"
                                 lazy="true"
                                 paginatorPosition="bottom"
                                 paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
                                 currentPageReportTemplate="{currentPage} of {totalPages} pages, {totalRecords} records"
                                 rowsPerPageTemplate="3, 6"
                                 >

                        <p:column headerText="Hospital Name" filterBy="#{subHosp.hospitalName}">
                            <h:outputText value="#{subHosp.hospitalName}"  />
                        </p:column>
                        <p:column headerText="Hospital Area">
                            <h:outputText value="#{subHosp.areaName}" />
                        </p:column>
                        <p:column headerText="Contact Person">
                            <h:outputText value="#{subHosp.contactPerson}" />
                        </p:column>

                    </p:dataTable>
                </p:panelGrid>
        </p:rowExpansion>
    </p:dataTable>

好像所有子表都共享同一个分页状态,如何将它们分开,让每个子表保持自己的分页状态?

标签: jspprimefaces

解决方案


推荐阅读