JavaScript library callback functions
You can define a callback function when you instantiate Websheet and CubeViewer objects. The callback function traps changes to the title dimensions in the related object so you can process the event.
Websheet and CubeViewer objects both use the same format for defining a callback function. You add the callback function directly within the function that instantiates the TM1® Web object. Your code to handle the event goes inside this function.
Format
The callback function is defined with the following format:
onTitleDimensionElementChange: function(elementInfo) {
// Add your code here to handle the title change event
}
When a change to a title dimension
is detected, the elementInfo
object is passed to
the callback function. The content of elementInfo
is
different for Websheet and CubeViewer objects. Use this information
to see which dimension title has changed.
- Websheet elementInfo object:
- sheetIndex
- Type: Integer
- rowIndex
- Type: Integer
- columnIndex
- Type: Integer
- dimension
- Type: String
- element
- Type: String
- elementIndex
- Type: Integer
- CubeViewer elementInfo object:
- dimension
- Type: String
- element
- Type: String
- elementIndex
- Type: Integer
Websheet callback function example
The following example shows a callback function that is defined within the function that loads a Websheet object.
function loadWebsheet() {
require([
"tm1web/api/Workbook"
], function(Workbook){
var loadedWebsheet = new Workbook({
sessionToken: "yourSessionToken",
path: "Applications/Planning Sample/Management Reporting/Actual v Budget",,
onLoad: function() {
console.debug("Workbook loaded successfully.");
},
onTitleDimensionElementChange: function(elementInfo) {
console.debug("Title dimension element changed:");
console.debug(elementInfo);
}
});
document.body.appendChild(loadedWebsheet.domNode);
loadedWebsheet.startup();
});
};
CubeViewer callback function example
The following example shows a callback function that is defined within the function that loads a CubeViewer object.
function loadCubeview() {
require([
"tm1web/api/CubeViewer"
], function(CubeViewer) {
var loadedCubeview = new CubeViewer({
sessionToken: "yourSessionToken",
cube: "plan_BudgetPlan",
view: "Budget Input Detailed",
isPublic: true,
onLoad: function() {
console.debug("CubeViewer loaded successfully.");
},
onTitleDimensionElementChange: function(elementInfo) {
console.debug("Title dimension element changed:");
console.debug(elementInfo);
}
});
document.body.appendChild(loadedCubeview.domNode);
loadedCubeview.startup();
});
};