JSFormBaseModel
GMSC 2013/2014 Javascript API | Overview • Form • Events • Types • Utility Functions • client-side Validation • Conditions • Interaction with SmartClient • Cookbook • Cheatsheet |
Form Models | BaseModel • FormModel • TabModel • GroupModel • Field Models • ActionModel |
Abstract Base Class that provides common methods and properties for FormModel, TabModel, GroupModel FieldModel, and ActionModel
Contents
Methods
show()
shows the form item (and all its sub-items)
Examples
show the form field 'TEST' in the current form
IG.form.getItemById('TEST').show();
hide()
hides the form item (and all its sub-items)
Examples
hide the form field 'TEST' in the current form
IG.form.getItemById('TEST').hide();
toggle()
toggles the form item (and all its sub-items), i.e. switch its state between hidden and visible.
Examples
toggle the form field 'TEST' in the current form
IG.form.getItemById('TEST').toggle();
disable()
disables the form item (and all its sub-items), i.e. making it non-editable.
Examples
disable the form field 'TEST' in the current form
IG.form.getItemById('TEST').disable();
enable()
enables the form item (and all its sub-items), i.e. making it editable.
Examples
enable the form field 'TEST' in the current form
IG.form.getItemById('TEST').enable();
serialize()
serizalizes the form item and all its sub-items meaning that a JSON object containing all the form items as key/value pairs is created. Can be used to persist a form on the server side. Attention: File input fields are not serialized.
Returns
{Object}
An object containing the form item(s) as key/value pairs.
Example
Running IG.form.serialize()
in the Browser's Javascript shell returns an object containing all the form fields as key/value pairs:
>>> JSON.stringify(IG.form.serialize()) "{"ConfigurationRequired":"True","Name":"sdf","Password":"sdf","Site":"GMSC_13"}"
isValid()
validates the given form items against their assigned validators (e.g. required, minLength,...). Returns true if the input of the form items matches the validators and false otherwise.
Returns
{Boolean}
result of the validation (always true if no validators were assigned).
Examples
validate the form field 'TEST' in the current form
IG.form.getItemById('TEST').isValid();
getSettings()
returns the raw JSON configuration of the form item as contained in IG.formSettings
. Can be used for debugging.
Returns
{Object}
the settings as nested JSON Objet.
Examples
retrieve the settings of form field 'TEST' in the current form
IG.form.getItemById('TEST').getSettings();
containsChild(childId)
returns true if the current element has any descendant element (e.g. child, grand child,...) with the given id.
Parameters
{String} childId
the id of the descendant element
Returns
{hasChild}
tells if the child was found or not.
Example
find form elements (fields, groups,...) that exist in the first form group of the field:
>>>IG.form.getGroups()[0].containsChild('Field2'); //Find out if the first form group contains a field with the id 'Field2' true >>>IG.form.getGroups()[0].containsChild('Field2Action'); //Find out if the first form group contains a field action with the id 'Field2Action' (which would be a grand-children of the form group). true
Properties
kind
{String}
the kind of the formitems, one of the following values: 'form', 'tab', 'group', 'field', 'action'
name
{Observable}
the name of the formitem, referring as unique id. Attention: being an observable, you have to access it like so:
IG.form.getItemById('TEST').name();
visible
{Observable} or {Computed}
the visibility state of the form item, either true or false.
Attention: being an observable, you have to access it like so:
IG.form.getItemById('TEST').visible();
form
{Observable}
property that refers to the current form instance.
editable
{Observable} or {Computed}
the editable state of the form item.
Attention: being an observable, you have to access it like so:
IG.form.getItemById('TEST').editable();
_jqNode
{jQuery Object}
the DOM node of the form element as jQuery object