For Each Line command

Official Content
This documentation is valid for:
Forces the processing of every loaded or selected line in a Grid.

Syntax

For each line [ in <GridName> ]
       code
Endfor

Where:

code
      Is the sequence of valid language commands.

Scope

Objects: Web Panel
Generators:   .NET .NET Framework Java, RPG, Cobol, Ruby (up to GeneXus X Evolution 3), Visual FoxPro (up to GeneXus X Evolution 3),  Android Apple

Note: Android Apple up to GeneXus X Evolution 2.

Description

This command allows you to process all or selected lines in a Grid. It can be used, for example, to mark all the lines that fulfill a specific condition.

For Each Line has the following properties and restrictions:

  • It only processes the records that have been loaded and are visible in the grid. Take into consideration that if the Grid has Paging, it will only process the current active page rows.
  • It processes all lines whether they have been modified or not.
  • The lines are processed in the same order as they were selected.

Notes:

  • If the For each line command is used In the Enter event, each line will be processed. However, it is the programmer's responsibility to update the grid values.
  • In non-visual generators, you can only select the line on which the cursor is (simple selection) positioned. In Visual FoxPro it is not possible to select many lines from a grid (it's a Visual FoxPro restriction and not of the generator).
  • This command is supported in nested Grids (since X Evolution 3 Upgrade 7). The external Grid must be a FreeStyle, and the parent row must be instantiated. In other words, the button that triggers the event must be inside the parent's grid or the event must be programmed in this way:
For Each Line in ExternalGrid
   For Each Line in InternalGrid
   ...
   Endfor
Endfor

Samples

Event Enter // We want to put an * to all processed lines
    For each line
        If &Op = '*' // If it already has an * we put '\'
           &Op = '\' 
        Endif
        If &Op = '/' // The line is processed
            Call ...
            &Op = '*'
        Endif
    Endfor
EndEvent

See Also

For Each command