Report Events¶
When extending CALUMO Published Reports with Javascript, a set of events can be used bind to to perform different actions when they fire
The best way to wire up your JavaScript to use these events is to use the report API:
report.api.bind("postrender", function(){
//
// Do Your Code Here
//
});
Below, is an example of a requirement to hide the Slice to Excel feature if the username is one of those specified. It assumes that a CINFO formula has been setup in A1 (R1C1), for example =CINFO("Username")
This example uses a library called underscore.js
report.api.bind("postrender", function(){
var currentUser = report.api.find('#R1C1').data().rawValue;
if (_([
'bob',
'mary',
'jhoover',
'pwood'
]).any(function(user) {
return currentUser.contains(user);
})) {
// Get the report toolbar element for the Send To Excel button and fade it out
report.api.find('#sliceToExcel').fadeOut();
}
});
The main technical requirements to know (and that can usually be ignored by just copy/pasting a working example) are:
- The namespace for using the API is report.api
- If you want to get a reference to an element within a report, you need to use report.api.find(“\<jQuery Selector>“)