How to update another component AFTER filtering lazy data Table in grids

is it possible to update other components AFTER filtering lazy data?

<p:dataTable id="dataTable" value="#{NewsBean.items}" binding="#{NewsBean.items.dataTable}" lazy="true" filteredValue="#{NewsBean.filter}" var="item" paginator="true" rows="10"
            currentPageReportTemplate="(Displaying results {startRecord} - {endRecord} of {totalRecords})"
            paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
            rowsPerPageTemplate="10,20,50,100,200,500,1000" filterEvent="enter">

            ...

            <p:ajax event="filter" update="some_other_component" />

            ...

</p:dataTable>
<p:blockUI block="dataTable" trigger="dataTable" />

The specific problem is that the filter event fires before my dataTable completes lazy filtering, and so the update event for another component will be fired at an early stage. Therefore, the component cannot display the specific contents of the filter. Filtering again will show the result one step earlier.

I found a solution from BalusC instead of a remote command.

<p:ajax event="filter" oncomplete="updateFilterSelection()" />
<p:remoteCommand name="updateFilterSelection" update="some_other_component" />

But using this solution will end up loading my block endlessly. It seems that an incomplete event is no longer triggered.

Is there any solution?

I use primary 3.5.

thank

EDIT: I found a solution for me that works as expected:

<p:ajax event="filter" listener="#{some_Method}" update="some_other_component" />

some_Method , . , .

+4
2

:

Lazy Data.
, Primefaces.

:

  • LazyDataModel load(): RequestContext.getCurrentInstance().execute("updateUserInterface()");
  • JavaScript:
    function updateUserInterface() {
    // Commands to update the user interface
    }
+2
update=":#{p:component('size')}"

- outputText.

-2

Source: https://habr.com/ru/post/1539578/


All Articles