Update asp.net core report after variable change

Stimulsoft Reports.WEB discussion
Post Reply
xnetdude
Posts: 7
Joined: Sat Feb 23, 2019 11:38 am

Update asp.net core report after variable change

Post by xnetdude »

I am really struggling to find an answer to this problem. It has been asked before but not definitive answer given.

We are using a trial of the asp.net Core 2019.2 version and are rendering reports in a Viewer within a partial view nicely. We have linked our datasource to SQL Server and have specified "Variables" for some of the conditions within the SQL "where" clause. This works great on first render with the variables being populated in the "GetReport" method in the Controller.

Here is the code for the Viewer instantiation within the partial view.

Code: Select all

@using Stimulsoft.Report.Mvc;

<table width="10" align="center">
    <tr>
        <td style="width: 100%;" align="center" valign="top">
            @Html.StiNetCoreViewer(new StiNetCoreViewerOptions()
       {
           Actions =
                    {
                        GetReport = "GetReport",
                        ViewerEvent = "ViewerEvent",
                    },

           Toolbar =
                {
               DisplayMode = Stimulsoft.Report.Web.StiToolbarDisplayMode.Simple,
                    ShowOpenButton = false,
                    ShowAboutButton = false,
                    Alignment = Stimulsoft.Report.Web.StiContentAlignment.Center,
                    BorderColor = System.Drawing.Color.White,
                    ShowRefreshButton = true,
                    },
           Appearance =
           {
               ShowTooltipsHelp = false,
               ShowPageShadow = true,
               PageBorderColor = System.Drawing.Color.White,
           },
           Exports =
           {
               ShowExportToDocument = false,
               ShowExportToSylk = false
           },
           Localization = "~/Localisation/Reporting/en-GB.xml",
       })
        </td>
    </tr>
</table>
We have a separate part of the page, also in a partial view, which allows the user to select certain criteria within a type of filter. Once they have selected their data, it then posts this selection data back to the Controller using AJAX.

All this is great and working well. What we cannot figure out is how to refresh the report Variables with this new posted-back data and have the report redraw. Is this done within the Controller and, if so, how do we tell the viewer to refresh (thus getting the new data) or is this done within the View and, if so, what is the correct method to call on the Viewer object.

Seems such a simple and common ask and I suspect we are missing something but have been working on this for days!

Thanks in advance for any guidance.
James.
Lech Kulikowski
Posts: 6247
Joined: Tue Mar 20, 2018 5:34 am

Re: Update asp.net core report after variable change

Post by Lech Kulikowski »

Hello,

For report refresh is needed to initialize request from viewer client side, you can make it with the following JavaScript code (use object with name js + viewer ID, by default - jsNetCoreViewer):

Code: Select all

<div onclick="jsNetCoreViewer1.postAction('Refresh');">Refresh Report</div>
Thank you.
xnetdude
Posts: 7
Joined: Sat Feb 23, 2019 11:38 am

Re: Update asp.net core report after variable change

Post by xnetdude »

Thank you Lech
Lech Kulikowski
Posts: 6247
Joined: Tue Mar 20, 2018 5:34 am

Re: Update asp.net core report after variable change

Post by Lech Kulikowski »

Hello

We are always glad to help you!
Please let us know if you need any additional help.

Thank you.
Post Reply