2013-12-23 68 views
1

我設置在顯示報告。該代碼的頁面的後臺我的報告的數據源是下面:如何使用telerik報告的客戶數據源添加過濾器?

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

現在,我想添加一些過濾器添加到類似的效果report.just那通過使用「Fields.XX = parameter.value」表達式在設計視圖中添加過濾器,因爲現在報表中沒有數據源,因此不能使用「Fields.XX ......」表達式。我怎樣才能通過後臺的程序來實現我的目標。順便說一句,我嘗試按代碼添加參數:

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

我可以得到參數。但仍然無法過濾數據。我怎麼解決這個問題?

任何建議表示讚賞, 最好的問候, 湯。

+0

有沒有人有答案? – Tangfb

回答

0
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... 
    } 
相關問題