【问题标题】:How to add filters with customer data source of telerik reporting?如何使用 Telerik 报告的客户数据源添加过滤器?
【发布时间】:2014-01-11 10:34:25
【问题描述】:

我在显示报表的页面后台设置了我的报表的数据源。代码如下:

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;
           }
       }

现在,我想在报表中添加一些过滤器。就像在设计视图中使用“Fields.XX=parameter.value”表达式添加过滤器的效果一样,因为现在报表中没有数据源,所以不能使用'Fields.XX......'表达式。我如何通过后台程序实现我的目标。 BTW,我尝试通过代码添加参数:

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

我可以得到参数。但仍然无法过滤数据。我该如何解决这个问题?

感谢任何建议, 最好的祝福, 唐。

【问题讨论】:

  • 有人有答案吗?

标签: asp.net datasource telerik-reporting


【解决方案1】:
 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...
    }

【讨论】:

    猜你喜欢
    • 2019-07-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-09
    • 2014-06-24
    相关资源
    最近更新 更多