Recents

Grids with Multiple Selection in Smart DevicesOfficial Content

Your application has one or more actions that may be applied to one or more selected items in a grid. GeneXus lets you scan all selected items in a Grid with the for each selected line command. The code to execute an action on all selected items will look as follows.

for each selected line [in <GridName>]
     <call_to_procedure>
endfor

Warning: The Procedure object must have only input parameters (output or hybrid parameters are not allowed)..

Adding multiple selections#

To further explain the use of multiple selection actions, we suppose that we have a set of customers and we want to apply a tax or 25% for some of them depending on their total amount.

Step 1 - Setting the UI behavior#

Previously, we create a Customer transaction object as follows and we apply the WorkWithDevices pattern.

image_2017815131110_1_png

In the Grid control from the List section of WorkWithDevicesCustomer, we will set the following properties:

  • Default Action property = <default>.
    In this case,  the end user is able to see the Detail section of the WorkWithDevicesCustomer when tapping in a register.
     
  • Enable Multiple Selection property = True
    For allowing multiple selections over Customer grid in the List Node.
     
  • Show Selector property = Always.
    It sets the user interface behavior for multiple item selections as always show its selector.

WWSD_-_Grid_Settings_jpg

Step 2 - Creating the action#

Create a new action called "Add tax" (right click on the Application Bar > Insert Button).

WWSD_-_Add_Action_jpg

This action will perform an ApplyTax procedure for updating the CustomerAmount by adding an interest of 25% on the selected items. In this procedure, we have to write the following code:

for each
     CustomerAmount = CustomerAmount * 1.25
endfor

The procedure must have a parm rule as it is shown below for automatically filter items in the for each command.

Parm(in:CustomerId);

3. Writing the action execution code#

Finally, we have to write the section code associated with the action 'Add tax' on the Event section as follows.

Event 'Add tax'
     Composite
          For each selected line in Grid1
               ApplyTax(CustomerId)
          Endfor
          Refresh
     EndComposite
EndEvent

Note:

  • For SDT or BC collection based Grids, the way to access to each item is by the CurrentItem runtime property.
    For example:
For each selected line in Grid1
    ApplyTax(&Customer.CurrentItem.CustomerId)
Endfor

where &Customer is a variable based on an SDT or BC item.

Application runtime behavior#

1. We have to select the items that we would like to update. Every item can be selected by tapping on the left check-box.
WWSD_-_Runtime_Selection_2017815134611_1_jpg

2. Once you finish the selection, tap on "Add tax" action for executing the action apply the 25% tax interest.
WWSD_-_Runtime_Selection_Action_jpg

3. After the refresh of the device, we can see the total amount has changed correctly.
WWSD_-_Runtime_After_Done_jpg

Notes#

  • If you have an action with several for each selected line over different Grids, the behavior of the User Interface is the platform default.
  • An attribute used in a for each selected line command must be present in the grid on the form to works correctly.
  • In the for each selected line in <grid> command, the grid's name is optional when you have only one grid in the SD Panel or WorkWithDevices object.
  • If the grid row theme class has highlighted background color, this color will be used to mark the selected items.
  • For Android devices, the selection user interface may depend on the operative system version.
  • Enable Multiple Selection property is available as of GeneXus 15 Upgrade 6. For previous upgrades, you must set Selection Flag property.



Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.