添加ajax事件后,排序列不再起作用

时间:2015-12-07 13:29:01

标签: ajax sorting jsf primefaces

jsf代码:

<p:dataTable styleClass="patientlistcolumns" id="patienttable" value="#{patientsBean.rows}" var="patientData"
emptyMessage="#{bundle.noRecordsFound}" paginator="true"
paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="20,50,100" rows="20" paginatorPosition="bottom" resizableColumns="true" resortMode="single"
draggableColumns="true" selection="#{patientsBean.selectedPatients}" rowKey="#{patientData.ID}"
paginatorAlwaysVisible="false" sortBy="#{patientsBean.sortField}">

    <p:ajax event="sort" listener="#{patientsBean.onSort}"/>
    <p:ajax event="rowSelect" listener="#{patientsBean.onRowSelect}" />
    <p:ajax event="colReorder" listener="#{patientsBean.onReorder}" />
    <p:ajax event="rowSelectCheckbox" update="@form" />
    <p:ajax event="rowUnselectCheckbox" update="@form" />
    <p:ajax event="toggleSelect" update="@form" />

    <p:column selectionMode="multiple" style="width:16px;text-align:center" selectRow="false" resizable="false"
      visible="#{patientsBean.multiSelectionEnabled}" />


    <p:columns id="patientColumns" var="columnIndex" value="#{patientsBean.columnIndices}"
      sortBy="#{patientData.getColumnValue(columnIndex).sortValue}">
      <ui:param name="column" value="#{patientData.getColumnValue(columnIndex)}" />

      <f:facet name="header">
        <h:outputText value="#{patientsBean.getColumnName(columnIndex)}" />
      </f:facet>

      <p:column rendered="#{column.displayType == 'TEXT' or column.displayType == 'LINK'}">
        <h:outputText value="#{column.value}" />
      </p:column>
    </p:columns>
 </p:dataTable>

bean代码:

public void onSort(SortEvent event) {
    onSort(event, MY_P);
}

一旦我添加了ajax事件,排序就不再起作用了。什么都没发生,听众我没有打电话。 没有ajax排序工作正常。

任何解决方案提案?会很好 :) 我需要保存排序,所以我真的需要ajax监听器。

1 个答案:

答案 0 :(得分:0)

我通过在后端将onSort(SortEvent事件)更改为onSort(AjaxBehaviourEvent事件)来解决问题。 您可以稍后将其转换为SortEvent .. 很遗憾,它在showCases上的解释不同