All visual components in Reportal have a "hide" expression. If this expression evaluates to true for a component, then this component is hidden from the report viewer. Additionally some components have "render" scripts used to dynamically modify the properties for the component before the component is rendered/displayed.
Note that you can use the CTRL+S keyboard shortcut to save changes when writing component scripts.
Render Scripts
Render scripts can be defined for the visual component types, to set properties for the components dynamically.
- Hide script
- Aggregated Table script
- Verbatim Table script
- Chart script
- Gauge script
- Hit List script
- Text script
Click the links for further details.
Hide Expression Script
Used to dynamically hide or show visual components on a report page.
|
Editor : Report tree > A Component > Script > Hide |
Main purpose: Hide a Reportal component conditionally. All components in Reportal can include a Hide expression. |
|
Description: A typical Hide expression could for example check whether or not a parameter is null. If more complex logic is required, consider using a script library function to implement this logic. | |
|
Example - Checking parameter : state.Parameters.GetString("p_show_hide") == "hide" | |
|
Example – Calling a library function new ReportCommon.MyLib().DoHide(state.Parameters)
| |
Note: All visual components on a page that have Hide scripts also have a Hide script in the Report Master.
Aggregated Table Script
|
Editor : Report tree > A Table > Script > Render |
Main purpose: Dynamically change the aggregated table based on for example parameter values or user information. |
|
Description: Use this script to dynamically add, remove or change headers for aggregated tables. If a table already has a banner or a parameter header, this script is called after the banner header is substituted with the header from within the banner and the parameter headers are substituted with a header for the current value for that parameter. | |
|
Example – Changing numbers of decimals: if(!state.Parameters.IsNull("p_table_dec") | |
|
Example - Adding a header: var hf : HeaderFormula = new HeaderFormula(); | |
|
Example – Changing a header: var hf : HeaderFormula = table.RowHeaders[0]; | |
Note: If you add a script to a table, caching is disabled for that table (go to Caching of Tables for more information).
Verbatim Table Script
|
Editor : Report tree > A Table > Script > Render |
Main purpose: Dynamically change the verbatim table based on for example parameter values or user information. |
|
Description: Most typical use of this script would be to dynamically set the questionnaire element of the table based on a parameter, but you can also change other properties of the verbatim table. | |
|
Example – Set questionnaire element:
| |
|
Example – Set sorting property: verbatimTable.Sorting = VerbatimSortingType.RespondentId;
| |
Chart Script
|
Editor : Report tree > A Table > Script > Render |
Main purpose: Dynamically change the chart based on parameter values or user information. |
|
Description: One way of using charts scripts is to allow the report user to decide dynamically the chart type and set the chart type based on a parameter in a script. If you set up a report in which the user can choose which question is to be used in tables and possibly also add one or more questions to the column headers, you may have to implement some logic regarding the parts of a table that are to be included in the chart. | |
|
Example – Setting chart type: if(!this.state.Parameters.IsNull("p_chart_type")) | |
|
Example – Setting part of table: chart.RowHeaderMask.AddHeader("benchmark");
| |
Gauge Script
|
Editor : Report tree > A Gauge > Script > Render |
Main purpose: Dynamically change the gauge based on parameter values or user information. |
|
Description: In this script you can add, remove or change exactly the same values as you can modify in the gauge style designer and gauge designer. | |
|
Example – Changing size of an existing circular gauge: var cg : CircularGauge = gauges.GetGauge("Gauge1"); | |
Hit List Script
|
Editor : Report tree > A Hit List > Script > Render |
Main purpose: Dynamically change the Hit List based on for example parameter values or user information. |
|
Description: In this script you can add, remove or change columns of the Hit List, and you can change the properties of the Hit List itself. | |
|
Example – Adding a column : var column : HitListColumn = new HitListColumn(); | |
Text Script
|
Editor : Report tree > A Table > Script > Render |
Main purpose: Dynamically set the text of a Text component based for example on parameter values or user information. |
|
Description: If a Text component has a script, any text set in the property sheet of the component will be overwritten. If your report is multilingual, you must also check the current language of the report to add the proper texts. One workaround for this may be to add your dynamic texts to an answer list in a multilingual survey and get the texts by using the | |
|
Example – Add some text : if(report.CurrentLanguage == 9) | |
|
Example – Add some text based on an answer text: var p : Project = report.DataSource.GetProject("ds0"); | |