ColdFusion 9.0 Resources |
cfreportparamDescriptionThe cfreportparam tag lets you perform the following tasks:
The cfreportparam tag is always a child tag of the cfreport tag. Syntax<cfreport template = ...> <cfreportparam chart = "name of the chart contained in the report or subreport" name = "data name" query = "query value passed to the chart or subreport" series = "ordinal number of a chart series" style = "CSS style definition or CSS file pathname" subreport = "name of the subreport" value = "data value"> </cfreport> Note: You can specify
this tag’s attributes in an attributeCollection attribute
whose value is a structure. Specify the structure name in the attributeCollection attribute
and use the tag’s attribute names as structure keys.
See alsocfreport; Creating Reports with Report Builder in the Developing ColdFusion Applications; Report Builder online Help HistoryColdFusion 8: Added the chart, query, series, subreport, and style attributes. ColdFusion MX 7: Added this tag. Attributes
UsageYou can specify only one of the following attributes in a cfreportparam tag:
You can use the query, subreport, and chart attributes to override Report Builder queries and chart information at run time. This way you can customize subreport and chart data from the CFM page without having to change the queries built into your report. For example, in Report Builder, you can create a master report that contains several subreports and populate each subreport with a different query. Instead of modifying the queries in Report Builder, you can customize your reports by creating modified queries on the ColdFusion calling page. The ColdFusion query must contain at least all of the columns included in the Report Builder query. Note: You cannot specify a subreport
query that depends on arguments from the master report. Instead,
you can define a CFML function or CFC method that returns the subreport
query given the arguments from the master report. ColdFusion calls this
code when it executes the subreport.
On the calling CFM page, you can specify a cfreportparam tag for any subreport and chart in the Report Builder report. The value of the subreport or chart attribute must match the Name property of the subreport or chart defined in the Report Builder report. (Charts are treated like subreports.) The following code shows a master report that contains two subreports and a chart with two chart series: <cfreport template="myreport.cfr" query="master" format="RTF"> <cfreportParam subreport="subreport1" query="subquery1"> <cfreportParam subreport="subreport2" query="subquery2"> <cfreportParam chart="chart1" series="1" query="chartquery1"> <cfreportParam chart="chart1" series="2" query="chartquery2"> <cfreportParam name="ReportDate" value="#DateFormat(Now())#, #TimeFormat(Now())#"> </cfreport> The cfreportparam tag also lets you override CSS styles assigned to subreports in Report Builder. Use the style attribute with the subreport attribute; the value of the subreport attribute must match the name of the subreport in Report Builder. The following code applies a style sheet to the master report and two different style sheets to the subreports: <cfreport template="myreport.cfr" style="myStyle.css" format="PDF"> <cfreportParam subreport="subreport1" style="subreport-style.css"> <cfreportParam subreport="subreport2" style="subreport-style.css"> </cfreport> For more information, see the section Using Cascading Style Sheets. Example<!--- The following example shows how to override a query in a Report Builder report from the CFM page. The cfreportparam tag adds the current date and time to the report.---> <cfquery name="coursedept" datasource="cfdocexamples"> SELECT Departments.Dept_ID as dDept_ID, Departments.Dept_Name, CourseList.Course_ID, CourseList.Dept_ID as cDept_ID, CourseList.CorNumber, CourseList.CorName, CourseList.CorLevel FROM Departments, CourseList WHERE Departments.Dept_ID = CourseList.Dept_ID ORDER BY CourseList.Dept_ID </cfquery> <cfreport format="PDF" template="FourthReport.cfr" query="#coursedept#" overwrite="yes"> <cfreportparam name="ReportTime" value="#DateFormat(Now())#, #TimeFormat(Now())#"> </cfreport> |