JSFormModel

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



Methods

JSFormModel inherits all methods from JSBaseModel


getItemById(itemId)


returns the form item (tab, group, field, action) referenced by the given id. This id value always corresponds to the name attribute you assigned to the form item in formsettings.xml. GMSC 07


Parameters

{String} itemId the id of the form item

Returns

{model} the model of the form item

Example

getting an item by id in the javascript console:

>>>IG.form.getItemById('Tab2Group4Field4');
IG.FieldModels.TextField {slaveFieldIds: Array[0], kind: "field", _jqNode: jQuery.fn.jQuery.init[1], init: function, _setupEventPropagation: function}

getFields()


returns all form fields contained in the form GMSC 2013


Returns

{ArrayOfObjects} An array of all field objects found in the form

Example

This example listens to the onFormReady event and hides the fourth field of the form if it exists.

IG.events.onFormReady(function(form){
   var fields = form.getFields();
   if (fields[3]){
      fields[3].hide();
   }
});

getItemsByAttr(filterObject)


returns a list of items with attributes matching the given list of criteria. GMSC 2013


Parameters

{Object} filterObject An object with attributes and functions to be matched. Structure: { {String} filterProperty: {String} filterValue or {Function} filterFunction (filterProperty)}


Returns

{ArrayOfObjects} An array of form items matching given filter object. An empty array is returned if no matches are found.


Examples

Basic filtering of string and observable attributes:

var visibleFormFields = IG.form.getItemsByAttr({kind: "field", isVisible: true}); //an array of all visible form fields

Filtering with match-function as given criteria:

//filterObjectValue returns true or false if parameter is euqal to "grid", "tab" or "group
var filterObjectValue = function(kind) {
	return ( $.inArray(kind, ['grid','tab','group']) >= 0 ); 
};
 
var gridTabGroupFields = IG.form.getItemsByAttr({kind: filterObjectValue); //an array of all grid, tab and group FieldModels

getTabs()


returns all form fields contained in the form. GMSC 2013


Returns

{ArrayOfObjects} An array of all tabs objects found in the form

Attributes

JSFormModel inherits all attributes from JSBaseModel