Scripting linked gadgets
Data selection gadgets send an onChange event to all gadgets that link to it. When a user changes a value in a data selection gadget, an onChange function is triggered in linked gadgets to update their contents with the new selection. You can customize this onChange function for each linked gadget.
JavaScript is used with linking gadgets to process and change values from data selection gadgets, interact with global variables on the dashboard, and change default report parameters.
Figure 6‑5 shows where you can add custom JavaScript to a linked field.
Each linked value can have its own customized onChange function. Adding script to a subscribed gadget event enables you to interact with and test the value of any or all user selections. The onChange function intercepts the user selected value before it is used with report, Reportlet, and import gadgets.
Figure 6‑5 Adding JavaScript to a link’s onChange event
For example, you can validate or change user selections, display custom dialogs, or send values to a JavaScript function. Scripts interact with the following data:
event
The event name, for example:
"ON_SELECTOR_GADGET_CHANGED"
data
The data object that includes the entire message published by the data selection gadget. The following example of a data object message is sent by a list gadget named PRODUCTLINE with Trains and Ships selected:
{value:{
_entry:{
'Gadget_f10549d7-b2b0-43f2-9f0a-387e0e2c2560':{
name:"PRODUCTLINE",
publisherRealName:"Gadget_f10549d7-b2b0-43f2-9f0a-387e0e2c2560",
values:["Trains", "Ships" ],
namevalues:[
{value:"Trains", display:"Trains"},
{value:"Ships", display:"Ships"}
],
semantic:"SEMANTIC_filter"}
},
_size:1
},
event:"ON_SELECTOR_GADGET_CHANGED"
}
publisher
The name of the gadget that published information, such as a list gadget that publishes user selected values. For example:
{
"_gadgetName": "Gadget_f10549d7-b2b0-43f2-9f0a-387e0e2c2560",
"_gadgetTitle": "PRODUCTLINE",
"_gadgetType": "selector",
"_tabName": "823a17bc-c0a7-4d46-84d2-a4726ad624ce",
"_tabTitle": "New Tab 1"
}
thisGadget
This object refers to the report or Reportlet gadget receiving the published message. You can use this data to verify values in parameters and set conditions for updating a linking gadget.
The following example shows the value of thisGadget for a BIRT report design file with a customer name parameter:
{
_gadgetName:"Gadget_95497566-9ce3-4fc6-8bde-3159ca69c173",
_gadgetTitle:"Report - Customer Order History",
_gadgetType:"viewer",
_tabName:"823a17bc-c0a7-4d46-84d2-a4726ad624ce",
_tabTitle:"New Tab 1",
_currentReportParameters:[
{
_:{initialize:(function (){} ),
_FACADE_INSTANCE:{},
_name:"Customer",
_value:"Saveley & Henriot, Co.",
_valueIsNull:false,
_isRequired:true,
_isMultiList:false,
_dataType:"String"
}
}
]
}