Professional knowledge and discussions about reporting tool

FineReport display parameter controls dynamically

Due to the needs of business, in many cases the need to achieve in a web report such an effect: When a condition is met, certain conditions before the query is displayed, as shown below, select the annual report, showing in the drop down box control; select month Daily, year and month displays a drop-down box controls; select Daily, displays the date controls: as shown.
annual report date control
monthly report date control
daily report date control
Here we look at how to achieve these effects in Web reporting software FineReport.
Report by visible controls (), invisible () attribute controls its visual and non-visual
var [Widget] = form.getWidgetByName(“[ParaName]”); //Get control via control name
[Widget].visible(); //Set the control visibility
[Widget].invisible(); //Set the control Invisible
Specific steps are as follows:
1. Open report sample
Open Sample:
2. Modify report dataset
The dataset amended as follows:
SELECT * FROM 订单 where 1=1 ${if(type==”日报”,”and format(订购日期,’yyyy-mm-dd’) = ‘” + date + “‘”,if(type==”月报”,”and month(订购日期) = “+ month + ” and year(订购日期) = ” + year ,”and year(订购日期) = ” + year ))}
Type parameter type is set to the default value daily, the parameter date set default values ​​for the string value 2010-01-03.
3. Reports table-like modification
The table-like style modified as follows:
Report template
Set to A3 forms, custom data, the actual value is displayed with the corresponding values ​​were: daily, date; monthly, years; annual, year.
Add the following formula in cell B3:=if(type==”日报”,$date,if(type==”月报”,$year+”.”+$month,$year))
4. Report Parameters interface settings
Set the parameter interface into the following styles:
report parameter interface
Set the control type parameter type drop-down box, custom value and the actual value is displayed values ​​are daily, monthly and annual reports.
Set the parameters for the control type year drop-down box, custom values ​​and actual values ​​are displayed for 2010,2011.
Set the control type parameter month for drop-down box, the value equation, fill in the actual value of the formula = range (1,6) can be.
Set the control type parameter date for date, the return value type is the default string.
5. JS Event
To the parameter type drop-down box controls to increase the edited event, the specific JS code is as follows: Report Controls js code
Note: This code determine the type parameter value, if daily newspaper, only the date controls, if monthly, year and month are displayed controls, if the annual report, only the year controls.
6. Save the report template
Click on the preview page, the effect is as shown above.