Display Table Detail from second datasource

4 posts, 0 answers
  1. Kurt Kluth
    Kurt Kluth avatar
    160 posts
    Member since:
    Oct 2009

    Posted 02 Oct Link to this post

    I have a report where someone could pass in a parameter to show "Detail" for the record.  The "detail" is tied to a second datasource within the Telerik Report.  I am unsure of how to get it to fire and show as it should.  I have added the primary datasource and displays the records in the group header.  

    Attached is an image of what my report looks like SQLDatasource1 is the primary datasource and uses parameters passed in to display.  If input parameter DetailFlag = true then I want to show the Detail Record which is tied to SQLDataSource2.  

    Tried the following in the code-behind but not displaying.

    Private Sub detail_ItemDataBound(sender As Object, e As EventArgs) Handles detail.ItemDataBound
        Dim section As Processing.ReportSection = TryCast(sender, Processing.ReportSection)
        If section.Report.Parameters("DetailFlag").Value = "True" Then
            Table1.Visible = True
        Else
            Table1.Visible = False
        End If
        section.Style.BackgroundColor = groupHeaderSection.Style.BackgroundColor
    End Sub
    Private Sub pageHeaderSection1_ItemDataBound(sender As Object, e As EventArgs) Handles pageHeaderSection1.ItemDataBound
        Dim section As Telerik.Reporting.Processing.PageSection = TryCast(sender, Processing.PageSection)
        Dim txtAsOf As Processing.TextBox = DirectCast(Processing.ElementTreeHelper.GetChildByName(section, "txtAsOf"), Processing.TextBox)
        Dim txtReportParam As Processing.TextBox = DirectCast(Processing.ElementTreeHelper.GetChildByName(section, "txtReportParam"), Processing.TextBox)
        txtAsOf.Value = "AS OF " & Today.ToString("MM/dd/yyyy")
        txtReportParam.Value = "FOR " & section.Report.Parameters("Area").Value.ToString & " - " & section.Report.Parameters("Status").Value.ToString
    End Sub
  2. Ivan Hristov
    Admin
    Ivan Hristov avatar
    161 posts

    Posted 05 Oct Link to this post

    Hi Kurt,

    The requested behavior can be achieved without writing any code - just by using the built-in Bindings for report items. In this case it is enough to make the detail section invisible based on the parameter value and the detail section will show/collapse as requested.

    Since the invisible items will still be processed, additional Binding can be set to the table so its data source will be set to null if the details do not need to be shown. This can be done with the following expression: =IIF(Parameters.paramDetails.Value = true, ReportItem.DataSource, null)

    I have attached a small .trdx example that demonstrates how such a scenario can be accomplished. I hope you will find it useful.

    Regards,
    Ivan Hristov
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Kurt Kluth
    Kurt Kluth avatar
    160 posts
    Member since:
    Oct 2009

    Posted 08 Oct in reply to Ivan Hristov Link to this post

    Thank you for the example as it has allowed me to get closer but I have an error when trying to show the detail. I have attached the error and believe it has to do with recordset being blank?  I was going to upload my exported tdrx file but unable to so because of restrictions.  
  4. Ivan Hristov
    Admin
    Ivan Hristov avatar
    161 posts

    Posted 5 days ago Link to this post

    Hello Kurt,

    This exception means that the detail section contains an expression addressing a "DataSource" property. Make sure the item used in the expression actually has such property. In the example I attached in my previous post, I used DataSource as reference to the current data item. Only data items like Report, Table, List, Crosstab, Graph and Map have this property, so please check if the expression is applied to a Data Item, otherwise the expression will not work.

    Hope this helps.

    Regards,
    Ivan Hristov
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top