Active Reports Report Application Tutorial (8) - Dynamic Filtering of Interactive Reports

original
2014/06/11 12:08
Reading 150

The user can use the ActiveReports parameter set to provide data to the text box or chart in the report, select a subset of data to display in a specific area of the report, or transfer data from the main report to a sub report. You can obtain data values in three ways: prompt for input; Get the value from the main report and transfer it to the sub report; Take values from Windows form or Web form.

1. Create Report File

Create an ActiveReports report file named rptOrderDetails.rdlx in the application. The project template used is an ActiveReports page report. After creation, select Convert to Continuous Page Layout (CPL) report from the VS report menu item to convert a fixed page report to a continuous page report.

2. Open Report Explorer and add the following three report parameters in the parameter node

Parameter 1: Name: ProductID
Data type: Integer
The question displayed when the user is prompted to enter a value: Product name:
Multi value: True
Parameter 2: Name: StartDate
Data type: DateTime
Prompt the user to enter a value Display question: Start date:
Parameter 3: Name: EndDate
Data type: DateTime
Prompt the user to enter a value Display question: deadline:

 

3. Open Report Explorer and create a report data source according to the following information

name: NWind_CHS
Type: Micorsoft OleDb Provider
OLE DB provider: Microsoft.Jet.OLEDB.4.0
Server or file name: Data\NWind_CHS.mdb

4. Add Dataset

Right click the newly created NWind_CHS data source and select Add Dataset menu item

4.1 Adding dataset parameters

Parameter 1: Name: Param1
Value:=[@ ProductID]
Parameter 2: Name: Param2
Value:=[@ ProductID]
Parameter 3: Name: Param3
Value:=[@ StartDate]
Parameter 4: Name: Param1
Value:=[@ EndDate]

Note: When adding a parameter setting value attribute, you can click the drop-down list, select the expression option, and then set the parameter value in the expression editing dialog box

 ActiveReports Report Function Presentation Expression Editor

4.2 Setting Other Attributes of Dataset

General - Name: OrderDetails

Query - Query:

 SELECT Order. Order ID, Order. Customer ID, Order. Order Date, Product. Product Name, Order Details. Quantity, Order Details. Unit Price, Order Details. Discount from (Order inner join order details  on Order. Order ID = Order details. Order ID) inner join product on Order details. Product ID = Product. Product ID) where (Order details. Product ID in (?) or - one in (?)) and DateDiff ("d",?, order date) > zero and DateDiff ("d",?, order date) < zero ORDER BY Order. Order ID;

Note: In the above query statement Where condition, the parameter query is used? Place holder,? The occurrence order of must be consistent with the parameter order defined in the dataset parameter. At the same time, you can also select the "" option? It is the query parameter setting method in Access. SQL Server needs to use the string starting with @ as the parameter.

5. Design report interface

Add the Table control to the report design interface from the Visual Studio toolbox, and drag the fields in the OrderDetails dataset to the corresponding columns in the Table. The design interface is as follows:

 ActiveReports report function display page report

6. Run program

Run the program by pressing F5, enter values in the parameter panel, and click the View Report button to get the following results:

 The ActiveReports report function displays report parameters

7. Custom report parameter panel

 

 

ActiveReports report processing supports the built-in report parameter panel. You can also provide a user-defined report parameter panel independent of the report viewer control. Similar implementation effects are as follows:

 ActiveReports Custom Report Parameters Panel

Then set the report parameters in the Click event of the Run Report button and run the report:

 protected void btnRun_Click( object sender, EventArgs e)
 {
 GrapeCity.ActiveReports.PageReport report1 = new GrapeCity.ActiveReports.PageReport( new System.IO.FileInfo(Server. MapPath(" PageReport1.rdlx ")));
 report1.Report.ReportParameters[0]. DefaultValue.Values.Add(txtParam. Text);
 WebViewer1.Report = report1;
 }

Source code download address:


http://www.gcpowertools.com.cn/products/activereports_demo.htm

 

This article is from“ Grapevine Control Blog ”Blog, please keep this source http://powertoolsteam.blog.51cto.com/2369428/1255841

Expand to read the full text
Loading
Click to lead the topic 📣 Post and join the discussion 🔥
Reward
zero comment
zero Collection
zero fabulous
 Back to top
Top