mercredi 30 septembre 2015

Primefaces - How to call method on ticking the SelectAll checkbox in dataTable through ajx

I need your help in calling a method from a backing bean once I ticked the SelectAll checkbox at the top of a dataTable. I am able to call the method ShowTotal once I ticked or unticked the checkbox of each individual item, however when I tick the SelectAll checkbox from the top, no listener is called. Here is my code:

<p:dataTable id="PendingRequests" var="hr" selection="#{hrdirector.selectedRequests}"
             value="#{hrdirector.listPendingRequests}" rowKey="#{hr.requestNo}"
             filteredValue="#{hrdirector.filteredRequests}" widgetVar="dataTableWidgetVar">
  <p:ajax event="rowSelectCheckbox" listener="#{hrdirector.ShowTotal}" process="@this" 
          update=":form:PendingRequests:sum"/>

  <p:ajax event="rowUnselectCheckbox" listener="#{hrdirector.ShowTotal}" process="@this"
          update=":form:PendingRequests:sum"/>

        <p:column selectionMode="multiple" style="width:16px;text-align:center"></p:column>
        <p:column headerText="Request No.">
            <h:outputText value="#{hr.requestNo}"/>
        </p:column>
        <p:column headerText="Request Amount">
            <h:outputText value="#{hr.requestAmount}"/>
        </p:column>
    </p:dataTable>

    <h:outputText id="Sum" value="#{hr.Sum}"/>

I tried to add the below code in the column which it has the selection, but it gave me an error:

<p:column selectionMode="multiple" style="width:16px;text-align:center">
<p:ajax listener="#{hrdirector.ShowTotal}" />
</p:column>




Aucun commentaire:

Enregistrer un commentaire