setEventListener
Sets an event listener.
Description
vcc.setEventListener(page: string|null, controller: string|null, event: string, callback: Function): void
You can set script event listeners programmatically. For setting static listeners, it is easier to use the dollar-sign notation.
Note: Use this function within an event.
Parameters
page
Page name.
controller
Unique ID of the control within the datasheet or script page.
event
The name of the event.
callback
The function which will handle the event.
Return values
none
Example
You have multiple similar pages, each starting with the characters ‘q4_’. You also have fields with identical names. You want to load the pages only if the export value of the related (connected) field is “allowed”. You can do this by writing lots of dollar-sign notation events, but you can also achieve the same result in one step instead.
Note: There can be only one listener for each event. If you previously set something, it will be replaced by setting another one.
vcc.getScriptPages().forEach(function(page) {
if ('q4_' === page.substr(0, 3)) {
vcc.setEventListener(page, null, 'checkBeforeLoad', function() {
return vcc.isSelected(page, 'allowed', 'export_value');
});
}
});
Comments
Can’t find what you need? Use the comment section below to connect with others, get answers from our experts, or share your ideas with us.
There are no comments yet.