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

Display Table Detail from second datasource

3 Answers 370 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kurt Kluth
Top achievements
Rank 1
Kurt Kluth asked on 02 Oct 2018, 03:13 PM

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

Attached is an image of what my report looks like SQLDatasource1 is the primary  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

3 Answers, 1 is accepted

Sort by
0
Ivan Hristov
Telerik team
answered on 05 Oct 2018, 02:29 PM
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
0
Kurt Kluth
Top achievements
Rank 1
answered on 08 Oct 2018, 03:10 PM
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  file but unable to so because of restrictions.  
0
Ivan Hristov
Telerik team
answered on 11 Oct 2018, 12:38 PM
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
Tags
General Discussions
Asked by
Kurt Kluth
Top achievements
Rank 1
Answers by
Ivan Hristov
Telerik team
Kurt Kluth
Top achievements
Rank 1
Share this question
or