4.2 Binding Queries
You can dynamically change the data binding of an element from within script by setting the “query” property.
if(parameter['type'] == 'Details') {
Table1.query = 'sales details';
}
else {
Table1.query = 'sales summary';
}
You should only change the “query” property from within the onInit Handler or onLoad Handler.
Query Compatibility
The data binding of an element specifies information other than just the query name, such as grouping and summary fields, and formula columns. If you change a query from within script, you must make sure that the new query is compatible with these other specifications.
For Table and Chart elements, a query is considered compatible if it contains the same grouping and summary columns specified in data binding. Since the table can adjust itself to accommodate any tabular data, no change in table layout is necessary.
Because Section elements have fixed layout, the compatibility rules are stricter. If you use script to change the query binding for a Section, the new query must contain exactly the same columns as the query that it replaces. Otherwise, the Section will not display the new columns and will use default values for all columns that are missing in the new query.
In practice, dynamic query binding is most useful when your reports have tables with the exact same columns, but with different conditions or data sources. Keep in mind however, that Report Bean are the preferred way to achieve component-based reporting and report reuse.
See Also
Binding Data to a Table Element, in Report Design.
Binding Data to a Chart Element, in Report Design.
Binding Data to a Section Element, in Report Design.
Running a Query, for information on executing a query without binding.
| << 4.1.3 Query Example | © 1996-2013 InetSoft Technology Corporation (v11.5) | 5 Report Handlers >> |