[Resolved]Lazy Datatable lost selection on pagination,onsort

UI Components for JSF
kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

21 Oct 2016, 16:23

Nikoas wrote:But I have a last problem, i dont know how to handle the ToggleSelectEvent ? How can i get list from object or cast to a list of object selected?

I have the solution to set/unset list with backing bean (requesting database directly for example) maintaining a boolean (for toggling state, selectAll / unselectAll) but this is less elegant...
I don't know of another way.

Nikoas
Posts: 57
Joined: 17 Apr 2012, 11:55

21 Oct 2016, 16:56

Ok, I finally got it to work !

I add listener to my ajaxEvent ToggleSelect :

Code: Select all

<p:ajax event="toggleSelect" global="false" immediate="true"  update=":usersManagerForm:usersTable:usersActions" listener="#{usersManagerBean.onToggleSelect}" />  

and i add method in my backingBean :

Code: Select all

    public void onToggleSelect(ToggleSelectEvent event) {
        List<Compte> comptesListOfCurrentPage = (List<Compte>) compteLazyDataModel.getWrappedData();
        if(event.isSelected()) {
            selectedComptesList.addAll(comptesListOfCurrentPage);
        } else {
            selectedComptesList.removeAll(comptesListOfCurrentPage);
        }
    }
And all seems to work very well !!!!

Thanks you very much kukeltje, for your help and your wasted time for me.

NOTE : I can't change topic status to resolve cause i'm not the creator...
Primefaces 5.3
Jboss Wildfly 9

nokiajavi
Posts: 61
Joined: 24 Feb 2013, 15:03
Location: España
Contact:

22 Oct 2016, 12:41

Thanks! I I have marked as resolved.

texasaggie
Posts: 1
Joined: 20 Feb 2014, 20:44

29 Nov 2017, 05:24

kukeltje wrote:
18 Oct 2016, 12:46
This issue won't get fixed. For the simple reason that it is very uncommon behaviour to retain the selection when sorting/paging/filtering. The reason being that it can be very hard for the user to unselect things after e.g. two sort/filter/paginate since he/she needs to know where it was. If you need to select more on in a certain resultset, increase the pagesize. And if you do need it, you can implement it very easily when using ajax based (un)selection.
One comment on this old thread is that we have a use case where the user may need to select a small number of item out of a larger list (say 500 or 5,000 items) to apply changes to. The paginator is effective in shortening the screen instead of having a 5,000 row table that would be unwieldy otherwise. If that is uncommon, what would be a suggestion on a paradigm to manage selections from a large list?
Server: JBoss EAP 7.x
JSF: 2.2
Primefaces: 6.1
JDK:8

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

29 Nov 2017, 18:32

Reduce the large list with filtering... Select from there and add to an additional list, other than the selections of the datatable

Betlista
Posts: 48
Joined: 05 Apr 2018, 09:51

17 Dec 2018, 12:47

I just wanted to add a note here, that when I implemented all methods from LazyDataModel (originally throwing UnsupportedOperationException) - load (at least one version depends on sortMode), getRowKey and getRowData, it works quite well in PF 6.2.

Biggest challenge is with getRowData(String rowKey), but I raised a new question here in a forum.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 33 guests