Script Library
You can save commonly-used scripts as functions in the Script Library. This allows you to easily reuse these scripts in multiple report elements and multiple reports. By saving common script tasks to the script library, you can keep your main scrips short, simple, and easy to maintain.
To understand the advantages of the Script Library, consider the script below, which computes the total of a table column in a report:
var total = 0;
for(var r = 1; r < table.length; r++) {
total += table[r][col];
}
This is a common task, which you might need to perform on different table columns, on different tables, and in different reports. Rather than writing the same script again and again for each case, you should reuse the original script. For example, you can save this simple script into the Script Library as a function called “tableTotal()”.
function tableTotal() {
var total = 0;
for(var r = 1; r < table.length; r++) {
total += table[r][col];
}
return total;
}
You can then execute the script by calling the “tableTotal()” function from within any element or report script. The following sections explain how to create and use JavaScript functions and the Script Library.
See Also
Functions, in Report Scripting, for details of the JavaScript function syntax.
Functions, in Dashboard Scripting, for details of the JavaScript function syntax.
Client-Side JavaScript, in Report Scripting, for information on storing client-side JavaScript functions.
Adding a Function to the Script Library, for instructions on adding a function to the Script Library.
| << Table Style Regions | © 1996-2013 InetSoft Technology Corporation (v11.4) | Adding a Function to the Script Library >> |