sfAddGroupItems
Adds a new row at the mentioned index in a group control.
Syntax
sfAddGroupItems(id, index, callback)
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
id | string | yes | Control id of the group control. |
index | number | no | Index at which the new row should be added in the group control. If no index is provided, the new row is added at the end of the group control. The index is a zero-based index. |
callback | function | no | Code block to be executed after the new row has been added. See callback function. |
Usage examples
Example 1
Let us consider a group control Products. To add a new row at the end of the group control,
sfAddGroupItems('control_products');
To add a new row at the second position (at index 1),
sfAddGroupItems('control_products', 1);
Example 2
Let us consider a group control Products and a readonly numeric field NumberOfProducts outside the group control that displays the total number of products in the group control. To add a new row at the second position (at index 1) and update the total displayed,
sfAddGroupItems('control_products', 1, function(){
var count = sfGetValue('control_numberofproducts');
sfSetValue('control_numberofproducts', count + 1);
});