Any way to detect existence of AddNamedItem in rpx script?

Posted by: softcomlimited on 1 September 2019, 4:55 pm EST

    • Post Options:
    • Link

    Posted 1 September 2019, 4:55 pm EST

    Hello,

    I was wondering if there is a save way to detect if “myinfo” exists in the rpx script when you preview from the End User Report Designer?

    When I run my app I load the report with

    rpt.LoadLayout(xtr)

    and then

    rpt.AddNamedItem(“myInfo”, myObject)

    and then I call “myInfo” when the report is running.

    However in End User Report Designer preview I don’t want to call “myInfo”. Is there a way to tell if “myInfo” does not yet exist or maybe if I am in preview mode?

    Thanks

    Brian

  • Posted 2 September 2019, 1:58 am EST

    Hello Brian,

    Sorry to mention that I don’t understand your actual requirement.

    What I understand, you are loading the report layout in your application and use the following code to add class reference:

     rpt.AddNamedItem("myInfo", myObject)
    

    After that, you saved the report layout using “SaveLayout” method of section report.

    Use the 'GrapeCity.ActiveReports.Designer.exe" (End User Designer)(located at C:\Program Files (x86)\GrapeCity\ActiveReports 12\Tools) to preview the report.

    And you want to detect if “myinfo” exists in the RPX script at the time of preview in above exe. If yes, then “rpt.AddNamedItem(“myInfo”, myObject)” is never saved in your RPX layout. You need to add it through code always to use the “myinfo” in your report. Hence, there is no reference of “myinfo” exists when you preview the report in End User designer

    If my understanding is incorrect, please explain in detail.

    Thanks,

    Mohit

  • Posted 2 September 2019, 9:21 am EST

    Mr Mohitg,

    Not quite. Let me explain another way.

    The rpx report is created using the End User Designer.

    There is some script that references “myInfo” so that when my app loads the rpt and runs it, the report uses the part of the script that references “myInfo” and everythings happens as it should.

    When you try preview in EUD obviously “myInfo” does not exist so you correctly get a script error.

    What I would like is to detect that I am in preview mode so that I can put script to test and bypass the part of the script that references “myInfo” and thus get to see the preview without having to manually comment-out the references to “myInfo”.

    Regards

    Brian

  • Posted 2 September 2019, 10:07 am EST

    Hello,

    For this, you need to customize the EUD. You need to handle the “DesignerTabChanged” event of the designer to change the script at the time of preview. Please refer to the following lines of code;

    
    Private Sub reportDesigner_DesignerChanged(sender As Object, e As DesignerTabChangedEventArgs)
            If reportDesigner.ReportType = DesignerReportType.Section Then
                If e.ActiveTab = DesignerTab.Preview Then
                    'Change the script here
                    CType(reportDesigner.Report, SectionReport).Script = ""
                    'To reload the report with new script
                    reportDesigner.ReportViewer.LoadDocument(reportDesigner.Report)
                End If
            End If
        End Sub
    
    

    Also, you can refer the attached sample for implementing the same.

    Hope it helps.

    Thanks,

    Mohit

    VB.NET.zip

  • Posted 2 September 2019, 12:53 pm EST

    Mr Mohitg,

    Oh, ok. I follow. The default designer is perfect for me so I did not think to change it. I will have a go at it.

    Thanks

    Brian

  • Posted 2 September 2019, 2:25 pm EST

    Hello Brian,

    Please take your time. Feel free to revert if you have any question regarding this.

    Thanks.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels