Datatable state loading

UI Components for JSF
Post Reply
hipdragon
Posts: 34
Joined: 23 Sep 2010, 02:47

13 Sep 2017, 21:11

I was curious what the best way to restore the DataTable State between sessions. I am building the TableState object from information i have stored. I have attempted to place it in the session map on @PostConstruct of the backing bean. But it does not seem to apply the TableState on first page render. If i make an ajax call to update the DataTable after the page has loaded it updates and displays the correct TableState.

I'm using SortMeta to enable multiple sorting, which requires UIColumn so using ViewAction didn't work.

Thanks

hipdragon
Posts: 34
Joined: 23 Sep 2010, 02:47

15 Sep 2017, 17:33

I found a possible solution and thought i should share. Not sure this is the best solution and would like some input if anyone has any. I added the following code to the bottom of the page.

Code: Select all

<h:form id="pageLoadForm">
    <p:remoteCommand name="onload" update=":dataTableForm" autoRun="true" />
</h:form>
This seems to update the page correctly. Since I'm using lazy loading i noticed that this produces a total of 3 calls. One on page load during the first request, then two ajax requests after page has loaded.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 47 guests