Item-specific Examples
In this section, you will learn how to work with item-specific events. These events are specific to only some types of objects, such as buttons, datagrids, surveys, and more. Here are examples of some of them:
Buttons
Suppose you have a button in your application that, by default, says "Submit." After a user performs a certain action, you want to change this label to "Continue." Here's how you would use item.setContent(content)
to achieve that:
var submitButton = item; // Assume 'item' refers to your button item
submitButton.setContent("Continue");
In this example, the label on the button originally assigned to the variable submitButton
will change from "Submit" to "Continue." This demonstrates how you can dynamically update the content of a button to reflect the current state of your application or guide the user through a multi-step process.
Datagrids
Suppose you have a datagrid in your application that displays a list of items. You want to get the data in the datagrid:
console.log(appPage.F_DataGrid1.getDisplayedData())
Surveys
We want to obtain the options of a survey item:
let options = item.getOptions();
// Retrieves an array of options for survey questions, each with a value and display property.
Dropdown
Suppose you have a dropdown item and you want to set values to it:
var theTitle = "";
var opts = page.F_DropDown.getOptions();
for(var i=0; i<opts.length; i++) {
var theItemTitle = get(get(opts,i), 'title');
var theItemValue = get(get(opts,i), 'value');
if(theItemValue === 'Red') {
theTitle = theItemTitle;
}
}