I. Overview
1. Problem description
A dynamic column means that the column name is used as a parameter, and the column name is typed in the query button and clicked on the search, the column will be displayed in the report, as shown in the following figure:
2. Implementation ideas
Use conditional fromatting to hide columns to achieve dynamic column effects.
II. Example
1. Prepare data
Create a new general report, create a data query ds1, the SQL statement is: SELECT * FROM Sales_Volume where Product='Milk''
2. Design table
Design the report form and drag the corresponding field to the cell, as shown in the following figure:
3. Add widgets
1) Add widgets
Add a label widget, a drop-down checkbox widget, and a query button to the parameter panel. As shown below:
The widget value of the label widget is a string type: Column name:
The widget name of the drop-down checkbox widget is: Column name
2) The data dictionary settings
The data dictionary settings of the drop-down checkbox are shown in the figure below:
4. Add conditional attributes
Select cells A1 to E1, add the column width condition formatting, and set the column width to 0 when the current value is not included in the column name parameter, as shown in the following figure:
5. Effect preview
1) PC terminal
Save the report, click the Pagination Preview, the effect is as shown in the figure below:
2) Mobile
III.Template download
The completed template can be found at: %FR_HOME%\webroot\WEB-INF\reportlets\doc-EN\Parameter\DynamicCol\Conditional_formatting_implement_dynamic_columns.cpt
Click to download the template: Conditional_formatting_implement_dynamic_columns.cpt