Versions Compared

Key

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


You now have the option to fetch the value of dependent fields in forms without writing explicit codes (data support class, listener files, and so on). The values in the dependent fields can now be automatically filtered based on the value changes in the independent fields by using thethe reloadItemData() API.

Info

The reloadItemData() API can only be used when the View ID is specified for the form item. This view ID will contain the COLUMN_ID that must be specified for the form item (field). The view specified for the form items must be 'Grid' only. All types of grid views supported by Canvas can be used for auto-populating dependent fields.
The API cannot be used when the raw keys/values are specified or when the data for the form item is being fetched through the data support classspecially class specially written for the form. If the data support class is not specified Canvas uses the default data support class. However, the default data support class does not hinder with the view ID specified.
The reloadItemData() API can be used to auto-populate dependent fields' values for the following form items:

  • Item Selector
  • Combo
  • Auto Suggest
  • Icon Combo

...

  1. Create a form, for example, BENE_DETAILS_ID.
  2. In BENE_DETAILS_ID form, do the following:

...

  1. create two combo fields for Bank Name and Branch Name.

...


  1. Image Added

...


  1. In the Settings window of the Bank Name and Branch Name fields, mention the VIEW ID as BENE_VIEW.

...


  1. Image Added

...


  1. Image Added

...


  1. In the Settings

...

  1. window of the Bank Name and Branch Name fields, mention the column names BANK_NAME (in the Key

...

  1. Column and Value Column )and BRANCH_NAME (in the Key

...

  1. Column and Value Column), respectively. The column names must match with the names provided in the database.

...


  1. Image Added

...


  1. Image Added

  2. In the listener JS file, use the fm.reloadItemData API to link both the fields and auto-populate the value in the Branch Name field. Sample code is as follows:

Code Block
languagejava
canvas.form.listeners.TestAdd = Class(canvas.Observable,
	 {
		constructor: function(config) 
			{
				this.fm = config.fm;
			},
registerHandlers: function() 
	{
		this.fm.registerHandler("cbxchange", "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); 

// Here, Bank_Name_ID is the form item ID for the Bank Name field. 
//Branch_Name_ID is the form item ID for the Branch Name Field. 
// BENE_DETAILS_ID is the form ID.
//itemId and filters are the filter conditions. 
//In this code, the Branch Name field value is being filtered based on the Bank Name. 

...

Info

To view the form in your end application, you must create a view and map the form to it. Then map the form view to the app and the app to a workspace.


Image RemovedImage Added

Image RemovedImage Added

Image RemovedImage Added