1

I have a <liferay-ui:search-container> displaying my results.

I enabled a rowChecker, so that each row becomes selectable by a check box.

It is placed in a form; in this way users can select more rows, then click on my "submit" button and the action is able to get ids of the selected rows.

But users are unable to select two rows present in different pages (for example, there is a pagination delta=5 and they need element 1 and 6).

I'm not able to figure a way to solve this problem.

Do you have any previous experience about?

Thank you

Pierpaolo Cira
  • 1,457
  • 17
  • 23
  • Well, form will only pass parameters available to it. When you move to other page of search container, you lose previous items. One work around can be on each pagination, you maintain selected items in request or session and process them on submit. – Pankaj Kathiriya May 19 '15 at 14:16
  • Problem is that, using taglib automatically provided buttons (e.g. next, previous, etc.) I'm not able to get the previous selected values (because taglib don't perform a sumbit, but just link to another PortletAction) – Pierpaolo Cira May 19 '15 at 14:21

1 Answers1

1

I see two solutions for your problem:

  1. Add an onchange handler to the checkboxes and send an AJAX request to store the selected items on the server:

    // Stub using AUI/YUI:
    AUI().use("node", function(A) {
      A.all("td.entry-selector input").on('change', function (e) {
        var checkbox = e.target;
        var selectionState = checkbox.get('checked');
        // Send the selection to the server - depends on the architecture of your portlet
        ...
      });
    });
    
  2. Use a separate button labeled "Remember selection" that posts the current selection.

You should show a text that indicates how much elements are selected and offer an option to deselect all elements again.

And you have to reset the list of selected elements when appropriate (e.g. for a new search) - not a trivial task. One of the reasons why many applications don't remember row selections across page requests.

Tobias Liefke
  • 8,637
  • 2
  • 41
  • 58