The Dialog class / ui.Dialog methods |
Inserts a new row in the specified list.
insertRow( name STRING, index INTEGER )
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.
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