Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The following are the JavaScript APIs that you can use to handle the data in the items:

#

Form Event Handlers

Description

1

fm.addCssClass(String fieldNames, String clsName, Integer index, String parent)

Adds any

component

form item-related CSS classes under the Form Manager.

2

fm.addForm(

String formId, [mode:<'edit'

Object formConfig)

Allows to add a sub-form within a form on the fly.

3

fm.addNext(String formId)

Adds a form in the multiform next to the available instance.

4

fm.model.applyModelData(Object obj, Boolean ignoreChanges, Boolean ignoreNullChanges)

Applies the changes made in the model data for the specific

fields

form items and then ignores the changes in the remaining

fields.5

form items.

fm.addTab(String tabPanelId, Object config, Integer index, String parent)Adds the tab to a Tab Panel form item.

fm.clearInvalid(String fieldName, Integer index, String parent)

Code Block
languagejs
fm.clearInvalid('EMAIL_ID');
// EMAIL_ID is the form item ID


Clears the values from the given invalid form item. The second and third parameters are required in case of a multiform only, where index of the multiform at which the

field

form item is present must be the second parameter, and the multiform ID must be the third parameter.

6

fm.clearUploadPanel(Array fieldNames)

Resets the files inside the

panel upload components

Upload Panel form items that exist in the form with respect to array of file names.

7

fm.clearValues(Array fieldNames, Boolean resetFlag, Integer index, String parent)

Code Block
languagejs
fm.clearValues(
fieldNames)
['EMAIL_ID']);
// EMAIL_ID is the form item ID


Clears the value of

a specific form fields.8

specific form item(s). When the 'resetFlag' parameter is set to true, the value of the form items is set to the initial values and when set to false, all the values on the form items are cleared. The default value for 'resetFalg' is false.

fm.createSliderThumbs(String fieldName, Integer noOfThumbs)Re-creates the slider thumbs dynamically for any one the Slider form item.
fm.displayMenu(String itemId, Object config, index, formId)Create and displays the menu for the Button form item.
fm.downLoadFile(Object config)Connects to the ExportServiceServelet and download a file from the server's uploaded files storage.

fm.exportForForms(String exportType, String title)

Exports the form content for printing or PDF conversion. It currently supports two export types – PDF and HTML.

9

fm.focus(String fieldName, Integer index, String parent)

Code Block
languagejs
fm.focus(['EMAIL_ID']);
// EMAIL_ID is the form item ID


Sets the focus to the given form item. The second and third parameters are required for multiform only, where the index of the multiform at which the

field

form item is present must be the second parameter, and the multiform ID must be the third parameter.

10
fm.getComboStoreCount(String fieldName, Integer index, String parent)Get the store count in a Combo form item.

fm.getDropDownDisplayValue(String fieldName, String keyValue, Integer index, String parent)

Returns the display value for the corresponding key value of a drop-down. This is applicable for drop-downs only. In case of multiform, the third and fourth parameters are necessary. The index of the multiform at which the drop-down is present should be the third parameter. The multiform ID must be the fourth parameter

.11

.

fm.getFieldDom(String fieldName)

Code Block
languagejs
fm.getFieldDom(['EMAIL_ID']);
// EMAIL_ID is the form item ID


Gets the form item DOM for the particular item in a form.
fm.getFocussedField()Gets the currently focused form item on the form.

fm.getForm()

Returns the DOM object of the form.

12

fm.getFormTitle(

String formId

)

Returns the title as per the metadata of the request Master Form ID.

13

fm.getFormView()

Returns the reference of the wrapper panel under which the entire form is rendered. The app layer requires this view where it wants to render the form. This in turn helps the Form Manager to prepare the configurations for Lazzy Loading of the form

components

items.

14

fm.getModelData()

Returns the form model data of the form items.

15

fm.getNumberOfSubForms(String formId)

Returns the number of instances or replica of the multiform is available in the screen.

16

fm.handlerEvent(String event, String fieldName, String value, Integer index, String parent)

Raises any event dynamically.

17

fm.isFieldValid(String fieldName, Integer index, String parent)

Validates a specific sub-form, such as in Tab Panels. It returns true if the sub-form is valid, else returns false.

18

fm.isFormDataChanged

Returns true or false to indicate whether the data displayed on the form is changed or not.

19

fm.isFormValid(Object config)

Validates all the

fields in

form items on the form. It first looks up for custom form validation provided by the app layer. You can execute it in case it is provided, otherwise use the default validation process. Then, you can execute the post default validation process in case it is registered. This returns true if the form is valid, else returns false.

20

fm.isTabFormValid(Object config, Integer index, String parent)

Validates all the

fields in

form items on the form by invoking the validateTabForm() method. It returns true if the form is valid, else returns false.

21

fm.isTabPanelExists()

Checks if the Tab Panel exists or not in the whole form. This method is included because when adding the form using the addform() method in the Form Manager instance, the form loses its padding when Tab Panel is rendered already. It returns

true

True if the Tab Panel exists in the form, else returns

false

False.

22

fm.isUploadPanelValid()

Validates the file upload

component

form item. If the

component

form item is mandatory and if the file queue is empty, then the

component

form item is validated. It returns

true

True if the file upload panel is valid, else returns

false

False.

23

fm.markInvalid(String fieldName, String msgKey, Integer index, String parent)

Marks the field
Code Block
languagejs
fm.markInvalid('EMAIL_ID');
// EMAIL_ID is the form item ID


Marks the form item as invalid with the given message.
The message should be added in the bundle key associated with the form or form item.

24

fm.registerHandler(String event, String fieldName, Function handler, Object scope)

Event handlers for all form

components

items have to be registered to the Form Manager using this method. This method updates the handler in the local register object to be used later when receiving the events from the model. This method requires the event for which the handler needs to be registered as the first parameter; Item ID of the

component

form item for which the event needs to be registered as the second parameter; the call back function that needs to be executed for the passed event as the third parameter; and finally the scope in which the handler needs to be executed as the fourth parameter.

25

fm.reloadData(String fieldName)

Loads the app item with the recent data values.

26

fm.removeAt(

String formIndex

Integer index, String formId)

Removes the multiform instance of a particular index.

27

fm.removeCssClass(String fieldNames, String clsName, Integer index, String parent)Removes any form item related CSS classes in a form or any sub-forms.

fm.removeForm(String formId)

Removes the sub-form from the main form.

28

fm.removeFrom(String formId, String

StartingIndex

start, String

EndingIndex

end)

Removes the multiform instances starting from a particular index onwards up to the ending index.

29
fm.removeTab(String tabPanelId, String formId, Integer index, String parent)Remove the tab from an Tab Panel item.

fm.reset()

Resets the values of the

fields in

form items on the form. This method can be added in the click event of the Clear or Reset button of the form.

30

fm.resetSubForms()

Resets all the sub forms. It can be used to reset the sub form on click of the Reset button.

31

fm.resetUploadPanel()

Resets the files added in the

upload component.32

Upload Panel form item.

fm.setActiveTab(String tabPanelId, String formId, Integer index, String parent)Activate a Tab Inner Panel. This method searches for the Tab Inner Panel, which is a sub-form (form ID). If it exists in the whole form, the method tries to match the sub-form's parent item's item ID with the Tab Panel ID and activate the respective tab.

fm.setAllowBlank(String fieldName, Boolean validation, Integer index, String parent)

Sets a specific

field

form item to be blank irrespective of whether it is defined as a mandatory

field

form item or not. The validation parameter must be a Boolean value – true or false.

33
fm.setAreaExpanded(String fieldName, Boolean flag, Integer index, String parent)Expand or collapses the form item set for the given form item.

fm.setDecimalPrecision(String fieldName,

keyValue

String decimalPrecision)

Sets the decimal precision for the

spinner field

Spinner form item. This needs to be implemented if the

spinner field

Spinner form item is part of a multiform.

34

fm.setDefaultValue(String fieldName,

keyValue

String value, Integer index, String parent)

Sets the decimal value for the

spinner field. This is applicable for the spinner field

Spinner form item only. This method takes the following four parameters – the Item ID of the spinner

field

form item, the decimal value the needs to be set, the index of the multiform at which the spinner is present if at all the spinner is part of the multiform, and the multiform ID. The third and fourth parameters are applicable in case of multiform only.

35

fm.setDisabledDates(String fieldName, String disabledDates, String disabledDatesText, Integer index, String parent)

Disables the given dates in the given date

field

form item. When the user selects the disabled date, the text given as disabled text is displayed.

36

fm.setDisabledDatesText(String fieldName, String disabledDatesText, Integer index, String parent)

Shows the given string when the user selects the disabled date on the given date control.

37

fm.setEnabledFields(

fieldName1, fieldName2..., showFlag

Array fieldNames, Boolean enableFlag, Integer index, String parent)

Enables or disables the form items based on the showFlag value.

38
fm.setEnabledTabs(String tabPanelId, String formIds, Boolean enableflag, Integer index, String parent)Enables or disables the tabs in a Tab Panel item.

fm.setFocus(String fieldName, Integer index, String parent)

Sets the focus on a specific

field

form item. It returns the JSON of the

field name

form item that is passed and its valid status.

fm.setLabel(String fieldName, String label, Integer index, String parent)

Code Block
languagejs
fm.
39
setLabel('EMAIL_ID','Gmail ID');
// EMAIL_ID is the form item ID
// Gmail ID is the form item's caption or label


Sets the dynamic label for a item on the form.

fm.

setMaxValue

maxValue(String fieldName,

keyValue

String value, Integer index, String parent)

Sets the maximum value for the

date field or spinner field

Date, Slider or Spinner form items. For the

date field

Date form item, the value must be in the DD/MM/YYYY format. The third and fourth parameters are required in case of a multiform only, where index of the multiform at which the

date or spinner field

Date, Slider or Spinner form item is present and parent is the multiform ID.

40

fm.

setMinValue

minValue(String fieldName,

keyValue

String value, Integer index, String parent)

Sets the minimum value for the

date field or spinner field

Date, Slider or Spinner form items. For the

date field

Date form item, the value must be in the DD/MM/YYYY format. The third and fourth parameters are required in case of a multiform only, where index of the multiform at which the

date or spinner field

Date, Slider or Spinner form item is present and parent is the multiform ID.

41

fm.setPanelTitle(String fieldName, String title, Integer index, String parent)Update the label or title for a specific form level containers, such as FIELD-SET, PANEL, INFOPANEL, UPLOADPANEL.
fm.
setVisibleFields(fieldName1, fieldName2..., showFlag
setReadOnlyFields(Array fieldNames, Boolean readOnlyFlag, Integer index, String parent)Makes read-only any form item rendered under 'this' Form Manager instance.
fm.setStepValue(String fieldName, String stepValue, Integer index, String parent)Sets the step value for the Spinner form item.

fm.setVisibleFields(String fieldNames, Boolean showFlag, Integer index, String parent)

Shows or hides the form items based on the showFlag value.

42
fm.submitForm(Object md)Submits the form model data to the server and gets the result.

fm.updateComboRawStore(String fieldName,

keyArray

Array keyArr,

valueArray

Array valueArr, Integer index, String parent)

Updates the given combo item with the given array of keys and array of values. It is applicable for drop-downs, item selector, icon combo, auto suggest, and image panels only. For image panel, the keys must be the IDs of the images and the values must be the source (src) of the images. The fourth and fifth parameters are required in case of multiform only, where index of the multiform at which the

field

form item is present is the fourth parameter and multiform ID is the fifth parameter.

43

fm.uploadFile(String state, Function handler)

Uploads the file in queue state and call backs the appropriate handler invoked by the developer to update the status.

44

fm.validateFields(String fieldName)

Validates a specific

field

form item. It returns true if the

field

form item is valid, else returns false.

fm.
45
validateFormPanelTabs(Array tabFormNames, String tabPanelId, Integer index, String parent)Validate the specified tabs and the items on the form.

fm.reloadItemData(Array fieldValueList, Integer index, String formId)

  • fieldvalueList – This parameter is applicable for single and multi forms. Filter conditions can be given as follows:
Code Block
languagejs
canvas.form.listeners.
TestAdd
BeneficiaryAdd = Class(canvas.Observable, 
{ 
	constructor: function(config) 
	
{ 
		
this.fm = config.fm; 
	
}, 
	registerHandlers: function()
	{ 
	this.fm.registerHandler(
"cbxchange",
CFEC.CHANGE,"Bank_Name_ID",
    function(fm, event, 
fieldName, value) 
	{ 
	  if (!canvas.isEmpty(value)) 
	
  { 
		
this.fm.reloadItemData([
		
{ 
			itemId : 'Branch_Name_ID', 
			filters : { BANK_NAME : [value] 
} 
		}]); 
	
  } 
	}); 
	} 
}); 
CFLR.registerListener("BENE_DETAILS_ID", canvas.form.listeners.
TestAdd
BeneficiaryAdd); 
  • Index and formId – These parameters are applicable for multiforms. These two parameters must be provided along with the fieldvalueList.
This API is used to auto-populate dependent field

Auto-populates the dependent form item's values based on the values selected in the independent

fields

form items. For more information

on how to use this API

, refer


Note:

Auto-populating Dependent Fields’ Values in Forms.

Note

This API can only be used when the View ID is specified for the form item. The API does not apply when the raw keys: raw values are specified or when the data for the form item is being fetched through data support class.