Page 2 of 2

Re: Blazor - add custom Viewer button

Posted: Mon Apr 26, 2021 8:25 pm
by Lech Kulikowski
Hello

Please let us know if you need any additional help.

Re: Blazor - add custom Viewer button

Posted: Fri Dec 09, 2022 11:36 am
by mrapi
Hi
after update from 2022.4.5 to 2023.1.1 above code is not working,got in console:

Code: Select all

Unhandled Exception:
 Microsoft.JSInterop.JSException: this.WebViewer1.SmallButton is not a function
 blazor.webassembly.js:1 TypeError: this.WebViewer1.SmallButton is not a function
works fine if I revert to 2022.4.5
thanks

Re: Blazor - add custom Viewer button

Posted: Mon Dec 12, 2022 6:16 am
by Max Shamanov
Hello,

We need some additional time to investigate the issue, we will let you know about the result.

Thank you.

Re: Blazor - add custom Viewer button

Posted: Mon Dec 12, 2022 2:01 pm
by Max Shamanov
Hello,

Form version 2023.1.1 we made some changes in Stimulsoft Blazor.
Now you need to use the following code in _Host.cshtml:

Code: Select all

 <script>
        var createButton = function () {
            // 'jsWebViewer1' is a 'js' prefix plus the component ID
            var customButton = this.jsWebViewer1.SmallButton("customButton", "Custom Button", "emptyImage");
            customButton.image.src = "icon.png";
            customButton.action = function () {
                alert("Custom Button Event");
            }
            var toolbarTable = this.jsWebViewer1.controls.toolbar.firstChild.firstChild;
            var buttonsTable = toolbarTable.rows[0].firstChild.firstChild;
            var customButtonCell = buttonsTable.rows[0].insertCell(0);
            customButtonCell.appendChild(customButton);
        }
    </script>
and this code at Viewer.razor:

Code: Select all

<StiBlazorViewer ID="WebViewer1" Report="@report" OnViewerAfterRender="@OnAfterRenderViewer" />

@code
{
    //Report object to use in viewer
    private StiReport report;

    protected override void OnInitialized()
    {
        base.OnInitialized();
        //Init base font
        StiFontCollection.AddFontFile($"Fonts/OpenSans-Regular.ttf");
        //Create empty report object
        report = new StiReport();
        //Load report template
        report.Load($"Reports/TwoSimpleLists.mrt");
    }

    private void OnAfterRenderViewer()
    {
        JSRuntime.InvokeVoidAsync("createButton");
    }

}
https://github.com/stimulsoft/Samples-B ... %20Toolbar

Thank you.

Re: Blazor - add custom Viewer button

Posted: Tue Dec 13, 2022 8:19 am
by mrapi
it is working.thanks!

Re: Blazor - add custom Viewer button

Posted: Tue Dec 13, 2022 8:21 am
by Max Shamanov
Hello,

You are Welcome!

Re: Blazor - add custom Viewer button

Posted: Fri Dec 13, 2024 3:14 pm
by mrapi
Hi
is the any change since v2024.2.5 (same with latest version 2025.1.1)?
got again that error:

Code: Select all

    Unhandled exception rendering component: Object of type 'Stimulsoft.Report.Blazor.StiBlazorViewer' does not have a property matching the name 'OnAfterRenderEvent'.
reverting to 2024.2.4 it is working

thanks

mrapi wrote: Wed Apr 21, 2021 11:00 am Hi
tried the code but got

Code: Select all

 Unhandled exception rendering component: Object of type 'Stimulsoft.Report.Blazor.StiBlazorViewer' does not have a property matching the name 'OnAfterRenderEvent'.
I have the latest version(2021.2.3)
thanks

Re: Blazor - add custom Viewer button

Posted: Sat Dec 14, 2024 9:55 am
by Max Shamanov
Hello,

Unfortunately, we couldn't reproduce the issue on our test samples with version 2025.1.1.
Please check the following link with our samples:
https://github.com/stimulsoft/Samples-R ... %20Toolbar

Thank you.

Re: Blazor - add custom Viewer button

Posted: Sat Dec 14, 2024 10:51 am
by mrapi
thanks,it is working,seems the event name was changed from OnAfterRenderEvent to OnViewerAfterRender

Re: Blazor - add custom Viewer button

Posted: Sat Dec 14, 2024 11:41 am
by Max Shamanov
Hello,

You are welcome.