Page 1 of 1

Custom button on Viewer toolbar

Posted: Thu Jun 23, 2022 4:01 pm
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 :)

Re: Custom button on Viewer toolbar

Posted: Fri Jun 24, 2022 11:17 am
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.

Re: Custom button on Viewer toolbar

Posted: Fri Jun 24, 2022 7:34 pm
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.

Re: Custom button on Viewer toolbar

Posted: Sat Jun 25, 2022 5:09 am
by Max Shamanov
Hello,

You are welcome!