This is a migrated thread and some comments may be shown as answers.

Parameters filter and subreports

1 Answer 139 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 08 Oct 2014, 07:11 AM
Hi, 

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()
        Try
            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 + "'"
            filters.Add(filterApoyo)
 
            Dim repProt As ReportProtocolo = DirectCast(rs.ReportDocument, ReportProtocolo)
            repProt.Filters.AddRange(filters)
        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, 

1 Answer, 1 is accepted

Sort by
0
Hinata
Top achievements
Rank 1
answered on 10 Oct 2014, 01:16 PM
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
Tags
General Discussions
Asked by
Jon
Top achievements
Rank 1
Answers by
Hinata
Top achievements
Rank 1
Share this question
or