Omnis Technical Note TNJC0006Dec 2013
for Omnis Studio 6.x or above
Creating Dynamic Subforms
There is a set of new client commands to open and manage the subforms in a Subform Set which you can execute using the $clientcommand() method. These client commands must be executed on the Omnis App Server in the context of the current remote form instance ($cinst); the $clientcommand() method will not work in a client-side method. The $clientcommand() method requires two parameters: the Command to be executed and a Row variable containing the parameters for the command, with the general syntax:
where $cinst is the current remote form instance. The following client commands are available for creating and managing Subform Sets.
creates a Subform Set within the current remote form instance based on a list of remote form classes specified in the formlist parameter (see below).
; where row-variable is row(setname, parent, flags, ordervar, formlist)
removes a set of subforms. All subforms in the set will be destructed and removed from their parent.
; where row-variable is row(setname) where setname is set to be removed.
adds a form to an existing subform set.
; where row-variable is row(setname, uniqueID, classname, params, title, left, top, width, height, modal)
removes a subform from an existing set and destructs it (removing it from its parent).
; where row-variable is row(setname, uniqueID, focus)
brings a subform in a set to the top of the stacking order, and gives it the focus. You must use this command to display a subform that has previously been minimized.
; where row-variable is row(setname, uniqueID)
The subform list
The formlist parameter required for the subformset_add command defines the subforms to be added initially to the subform set (this list can be empty), i.e. a list of remote form classes that you have previously created in your library. The order of the forms in this list represents the stacking order from top to bottom, so that once the set has been added, the top-most subform will be for line 1, and the bottom-most subform will be for the last line.
Using the Stacking Order Variable (ordervar)
When you use the subformset_add client command a list called ordervar is created containing a list of the subforms in the subform set. The ordervar variable allows you to manage the subforms in the set. It has the same definition as the formlist, and like the formlist it contains the subforms in the order of the top to the bottom of the stacking order. Note that if coordinates have been centered using kSFScenter, the ordervar contains their actual values rather than the value kSFScenter.
Subform Set Examples
In the latter example, the list of remote forms to be used in the subform set is created in the $construct method of the remote form and the subform set itself is created using the subformset_add command. First the ‘formlist’ or list of forms for the subform set is defined and populated. Note that 'jsSubformSetForm' is a remote form contained in the library and the initial content for subforms can be sent in the Form parameters.