Parameters filter and subreports

2 posts, 0 answers
  1. Jon
    Jon avatar
    4 posts
    Member since:
    Mar 2013

    Posted 08 Oct 2014 Link to this post


    I'm not able to filter data in my subreport. I'm trying to add filters to a report and a subreport with the following code. As you can see, I define a filter for the report according to the value selected in a ASP.NET dropdown control. Filters works fine in report (using fillters.addrange method), but it's impossible for subreport.

        Protected Sub Search()
                Dim rs As InstanceReportSource = DirectCast(Me.rviewer.ReportSource, InstanceReportSource)
                Dim filters As New Telerik.Reporting.FilterCollection
                Dim filterApoyo As New Filter()
                filterApoyo.Expression = "=Fields.IdApoyo"
                filterApoyo.Operator = FilterOperator.Equal
                filterApoyo.Value = "='" + ddlApoyos.SelectedValue + "'"
                Dim repProt As ReportProtocolo = DirectCast(rs.ReportDocument, ReportProtocolo)
            Catch ex As Exception
                Throw ex
            End Try
        End Sub

    (Note I have not added code for subreport filtering, because I tried a lot of different options and didn't work.) 

    Is there any example to add filters programatically to a subreport, please? I can only see examples for reports... 

    Thanks in advance. Best regards, 
  2. Hinata
    Hinata avatar
    146 posts
    Member since:
    Dec 2013

    Posted 10 Oct 2014 in reply to Jon Link to this post

    Hi Jon,

    The SubReport item has a ReportSource property which specifies the sub-report. You need to find the SubReport item from within the master report, retrieve the sub-report from the SubReport.ReportSource and then apply the same modification to the sub-report as in your code snippet:

    Dim subReportItem = TryCast(repProt.Items.Find("subReport1", True)(0), Telerik.Reporting.SubReport)
    'cast the SubReport.ReportSource to the appropriate report source type e.g., TypeReportSource
    Dim subReportSource = TryCast(subReportItem.ReportSource, TypeReportSource)
    Dim subReportObject = Activator.CreateInstance(subReportSource.TypeName)
    'apply filters to the subReportObject here
Back to Top