简体   繁体   中英

How to add filters with customer data source of telerik reporting?

I set my report's data source in the backstage of the page that display the report.The code is below:

protected void Page_Load(object sender, EventArgs e)
       {
           if (!IsPostBack)
           {
               string acceptedStatus = QuoteStatusEnum.Accepted.ToString();
               string rejectedStatus = QuoteStatusEnum.Rejected.ToString();
               string canceledStatus = QuoteStatusEnum.Canceled.ToString();
               IList<QuoteRequest> list = ServiceFactory.QuoteRequestService.QueryItems(p => (p.QuoteRequestStatus.QuoteRequestStatusName == acceptedStatus) ||
                                                                                       (p.QuoteRequestStatus.QuoteRequestStatusName == rejectedStatus) ||
                                                                                       (p.QuoteRequestStatus.QuoteRequestStatusName == canceledStatus)).OrderBy(p => p.CreatedBy).ToList();
               var data = from d in list
                          select new
                          {
                              ClientName = d.Client.CompanyName,
                              Client = d.Client.ClientID,
                              CompanyName = d.Client.CompanyName,
                              QuoteNumber = d.QuoteNumber,
                              PropertyAddress = d.Property.PropertyAddressLine1 + (string.IsNullOrEmpty(d.Property.PropertyAddressLine2) ? "" : " ," + d.Property.PropertyAddressLine2),
                              QuotePrice = d.QuotePrice.HasValue ? d.QuotePrice.Value : 0,
                              ClientContact = ServiceFactory.ContactService.Read(p => p.ContactID == d.ClientContactID).FirstName + " " + ServiceFactory.ContactService.Read(p => p.ContactID == d.ClientContactID).LastName,
                              IsConverted = d.QuoteRequestStatus.QuoteRequestStatusName == "Accepted" ? "Yes" : "No",
                              ModifiedDate = d.ModifiedDate ?? DateTime.Now.AddYears(-10)
                          };

               int pastDueCount = list.Count(p => p.ClientDueDate < DateTime.Today);

               var instanceReporSouce = new InstanceReportSource();
               instanceReporSouce.ReportDocument = new CompletedQuotesReport();

               instanceReporSouce.ReportDocument.Reports.First().DataSource = data;
               ReportViewer1.ReportSource = instanceReporSouce;
           }
       }

Now, I want to add some filter to the report.just like the effect that add filter in the design view by using "Fields.XX=parameter.value" expression,For there is no data source in the report now,so it can't be use 'Fields.XX......' expressions.How can i achieve my goal by programs in the backstage. BTW,I try to add parameter by code:

instanceReporSouce.ReportDocument.Reports.First().ReportParameters.Add(new ReportParameter("TotalAccepted", ReportParameterType.String, "TotalAccepted:" + list.Count(p => p.QuoteRequestStatus.QuoteRequestStatusName == acceptedStatus)));

I can get the parameters. but still can't filter data. How can i solve this problem?

Any suggestion is appreciated, Best regards, Tang.

 private void RegisterByDept_NeedDataSource(object sender, EventArgs e)
    {
        string groupBy = string.Empty;
        string sortBy = string.Empty;

        Telerik.Reporting.Processing.Report report = (Telerik.Reporting.Processing.Report)sender;
        var payoutUID = report.Parameters["payoutUID"].Value.ToString();
        // some code here...
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM