无法在多列上对素数的数据表进行排序?

问题描述 投票:0回答:1

我尝试对具有两列的数据表进行排序,但失败。

我正在使用primefaces7,我试图用两列对数据表进行排序,但失败了。

[我遵循了primefaces展示上的示例:https://www.primefaces.org/showcase/ui/data/datatable/sort.xhtml,将sortMode的值设置为multi,并还设置了两列的sortby属性。

在应用程序启动后,每次单击两个排序列中的任何一个时,后端列表SortMeta的大小为1,那么我只能使用两个排序列之一对数据表进行排序,而不能同时对它们进行排序。

xhtml代码:

<p:dataTable var="hosp"
             binding = "#{hospitalController.sortTable}"
             value="#{hospitalController.hospitalLazyModel}"
             paginator="true"
             rows="7"
             paginatorPosition="bottom"
             paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
             currentPageReportTemplate="{currentPage} of {totalPages} pages, {totalRecords} records"
             rowsPerPageTemplate="7,15,30"
             lazy="true"
             id="sortTable"
             widgetVar="sortTable"
             sortMode="multiple"
             >

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

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

后端代码:


    public List<StdHospital> load(int first, int pageSize, List<SortMeta> multiSortMeta, Map<String, Object> filters) {
        // here it always prints 1
        log.info("multiSortMeta size -> " + multiSortMeta.size());

我是说我只能通过List SortMeta获得两列的一种排序信息,但是,由于后端的SortMeta类型是一个List,为什么它不包含两列的排序信息,例如排序顺序等等?

如何使用两列对数据表进行排序?

jsf primefaces
1个回答
0
投票

作为documentation says

通过将sortMode设置为multiple,可以进行多种分类。在在此模式下,单击排序列当metakey处于打开状态会添加排序列到订单组。

在Windows上,这意味着保持按下[ctrl]-键]在单击要排序的列时。在不同的操作系统,键盘布局和输入方法(例如触摸设备)上,可能会有所不同。

随时在其他OS / Input变体上进行测试,并将其编辑为答案。

© www.soinside.com 2019 - 2024. All rights reserved.