ui.Dialog.insertRow

Inserts a new row in the specified list.

Syntax

insertRow(
   name STRING,
   index INTEGER )
  1. name is the screen array name.
  2. index is the index where the row must be inserted (starts at 1).

Usage

The insertRow() method inserts a row in the list at a given position. This method does not set the current row or raise any BEFORE ROW / BEFORE INSERT / AFTER INSERT / AFTER ROW control blocks. It is quite similar to inserting a new element in the program array, except the internal registers are automatically updated (like the total number of rows returned by getArrayLength()). If the list was decorated with cell attributes, the program array defining the attributes will also be synchronized. If multi-row selection is enabled, selection flags of existing rows are kept. Selection information is synchronized (i.e. flags are shifted down) for all rows after the new inserted row.

This method must not be called in control blocks such as BEFORE ROW, AFTER ROW, BEFORE INSERT, AFTER INSERT, BEFORE DELETE, AFTER DELETE, it is designed to be used in an ON ACTION block.

After the method is called, a new row is created in the program array, so you can assign values to the variables before the control goes back to the user. The getArrayLength() method will return the new row count.

The method does not set the current row and does not give the focus to the list; you need to call setCurrentRow() and execute NEXT FIELD if you want to give the focus.

The insertRow() method must not be used when controlling a tree view. You must use the insertNode() method instead.

If the index is greater than the number of rows, a new row will be appended at the end or the list. This will be equivalent to call the appendRow() method.

If the list is empty, getCurrentRow() will return zero. So you must test this and use 1 instead to reference the first row otherwise you can get -1326 errors when using the program array.

This example shows a user-defined action to insert ten rows in the list at the current position:
ON ACTION insert_some_rows 
  LET r = DIALOG.getCurrentRow("sa")
  IF r == 0 THEN LET r = 1 END IF
  FOR i = 10 TO 1 STEP -1
    CALL DIALOG.insertRow("sa", r)
    LET p_items[r].item_quantity = 1.00
  END FOR