Custom button on Viewer toolbar
Posted: Thu Jun 23, 2022 4:01 pm
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.
I am showing my viewer through iframe, if it matters. Hope that I can get the answer here 
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>
