ActiveReports Report Application tutorial (8) --- Dynamic Filtering of interactive reports

Source: Internet
Author: User

You can use the ActiveReports parameter (Parameters) set to provide the data to the text box or chart in the report, or select a subset of the data to display in a specific area of the report, you can also transmit data from the main report to a subreport. You can obtain data values in three ways: prompt the user to enter the value, pass the value from the main report to the subreport, and set the value from Windows form or Web form.

1. Create a report file

Create an application named rptOrderDetails. the ActiveReports report file of rdlx uses the ActiveReports page report as the project template. After the report is created, select convert to continuous page layout (CPL) Report from the report menu items of, converts a fixed-page report to a continuous report.

2. Open the report resource manager and add the following three report parameters to the parameter node:
Parameter 1: Name: ProductID
Data Type: Integer
Prompt the user to enter a value to display the problem: Product Name:
Multi-value: True
Parameter 2: Name: StartDate
Data Type: DateTime
The following error is prompted: Start Date:
Parameter 3: Name: EndDate
Data Type: DateTime
Prompt the user to enter a value to display the problem: End Date:

 

3. Open the report resource manager 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 a dataset

Right-click the new NWind_CHS data source and choose add dataset menu item.

4.1 Add 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 the 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.

650) this. width = 650; "width =" 644 "height =" 338 "title =" ActiveReports report function display expression Editor "style =" border-width: 0px; display: inline; "alt =" ActiveReports report function presentation expression Editor "src =" http://www.bkjia.com/uploads/allimg/131228/2045096015-0.png "border =" 0 "/>

4.2 set other dataset attributes

General-Name: OrderDetails

Query-query:

 
SELECT order. order ID, order. customer ID, order. date of order, product. product Name, order details. quantity, order details. unit price, order details. discount from (Order innerjoin order details on order. order ID = order details. order ID) innerjoin product on order details. product ID = product. product ID) where (Order details. product ID in (?) Or-1in (?)) AndDateDiff ("d ",?, Order Date)> 0 andDateDiff ("d ",?, Order Date) <0 ORDERBY Order. Order ID;

Note: The Where condition of the preceding query statement uses the parameter query. What is the parameter used? Placeholder ,? The order of appearance must be consistent with the order of the parameters defined in the dataset. At the same time ,? Is the way to set query parameters in Access, SQL Server needs to use strings starting with @ as parameters.

5. design the report page

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

650) this. width = 650; "width =" 644 "height =" 296 "title =" ActiveReports report function display page report "style =" border-width: 0px; display: inline; "alt =" ActiveReports report function display page report "src =" http://www.bkjia.com/uploads/allimg/131228/20450951T-1.png "border =" 0 "/>

6. Run the program

Run the program by pressing F5, enter a value in the parameter panel, and click View Report. The following results are displayed:

650) this. width = 650; "width =" 644 "height =" 308 "title =" ActiveReports report function display report Parameters "style =" border-width: 0px; display: inline; "alt =" ActiveReports report function display report Parameters "src =" http://www.bkjia.com/uploads/allimg/131228/20450962T-2.png "border =" 0 "/>

7. Custom report parameters panel

 

 

ActiveReports Report Processing supports the built-in report parameter panel. You can also provide a custom report parameter panel independent of the report Viewer control. Similar implementations are as follows:

650) this. width = 650; "width =" 644 "height =" 354 "title =" ActiveReports custom report parameter panel "style =" border-width: 0px; display: inline; "alt =" ActiveReports custom report parameters panel "src =" http://www.bkjia.com/uploads/allimg/131228/2045091535-3.png "border =" 0 "/>

Then, set the report parameters in the Click Event of the "Run Report" button and run the report:

protectedvoid 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:


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

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/20450910A-4.png "/>

 

This article from the "grape city control blog" blog, please be sure to keep this source http://powertoolsteam.blog.51cto.com/2369428/1255841

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.