Custom button on Viewer toolbar

Stimulsoft Reports.NET discussion
Post Reply
ProZoomZoom
Posts: 2
Joined: Tue Jun 21, 2022 2:54 pm

Custom button on Viewer toolbar

Post by ProZoomZoom »

Since there is no "Refresh document" button on StiNetCoreViewer, I need to implement one myself. I checked the forum, found a lot of topics on how to add buttons in Angular, but no topic how can I do it on c#. I tried to put the script in the cshtml file, like this, but while debugging I saw, that jsStiNetCoreViewer.controls.toolbar is undefined on the moment when I try to get the toolbarTable.

Code: Select all

@{
    ViewBag.Title = "Stimulsoft Reports.Web Demo";
}

@Html.StiNetCoreViewer("StiNetCoreViewer", @ViewBag.ViewerOptions as StiNetCoreViewerOptions)

<script type="text/jscript">
    var userButton = jsStiNetCoreViewer.SmallButton("userButton", "My Button"); // (name, captionText, imageName, toolTip, arrow, styleName);
    userButton.action = function () { alert("My Button Event"); }
    var toolbarTable = jsStiNetCoreViewer.controls.toolbar.firstChild.firstChild;
    var buttonsTable = toolbarTable.rows[0].firstChild.firstChild;
    var userButtonCell = buttonsTable.rows[0].insertCell(0);
    userButtonCell.className = "stiMvcViewerClearAllStyles";
    userButtonCell.appendChild(userButton);
</script>
I am showing my viewer through iframe, if it matters. Hope that I can get the answer here :)
Max Shamanov
Posts: 768
Joined: Tue Sep 07, 2021 10:11 am

Re: Custom button on Viewer toolbar

Post by Max Shamanov »

Hello,

Please check the following sample:
If this does not help. Please, send us a sample project that reproduces the issue.

Thank you.
ProZoomZoom
Posts: 2
Joined: Tue Jun 21, 2022 2:54 pm

Re: Custom button on Viewer toolbar

Post by ProZoomZoom »

Max Shamanov wrote: Fri Jun 24, 2022 11:17 am Hello,

Please check the following sample:
If this does not help. Please, send us a sample project that reproduces the issue.

Thank you.
Hello!
Thank you very much, this one worked out for me.
Max Shamanov
Posts: 768
Joined: Tue Sep 07, 2021 10:11 am

Re: Custom button on Viewer toolbar

Post by Max Shamanov »

Hello,

You are welcome!
Post Reply