JSFormBaseModel

From GeoMedia Smart Client
Jump to: navigation, search
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

Methods

show()


shows the form item (and all its sub-items) GMSC 07

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) GMSC 07

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. GMSC 07

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. GMSC 07

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. GMSC 07

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. GMSC 07


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. GMSC 07


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. GMSC 2013


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. GMSC 2014

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' GMSC 2013

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. GMSC 2013

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. GMSC 2014

editable


{Observable} or {Computed} the editable state of the form item. GMSC 2013

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 GMSC 2013