Page 1 of 1

How to add custom button to mvc viewer toolbar?

Posted: Tue Apr 21, 2015 12:30 pm
by hfirst
I am using @Html.Stimulsoft().StiMvcViewer to display the print preview window in the browser from an asp.net mvc app. I'd like to insert a custom toolbar 'Back' button all the way to the left so that the user can go back to the report setup screen. Is this possible?

Re: How to add custom button to mvc viewer toolbar?

Posted: Wed Apr 22, 2015 8:11 am
by HighAley
Hello.

The print preview is opened in a new window. To return back you should just close the window.

Thank you.

Re: How to add custom button to mvc viewer toolbar?

Posted: Wed Apr 22, 2015 12:27 pm
by hfirst
Let me rephrase what I meant by print preview window. I am launching a url and that page displays your report. It has your toolbar at the top. I'd like to add a button (and attach some javascript to it) so they can go back to the previous url/page.

Re: How to add custom button to mvc viewer toolbar?

Posted: Thu Apr 23, 2015 11:35 am
by Vladimir
Hello,

You can use the following Javascript code for this:

Code: Select all

<script type="text/jscript">
    var userButton = jsMvcViewer1.SmallButton("userButton", "My Button", "emptyImage"); // (name, captionText, imageName, toolTip, arrow, styleName);
    userButton.image.src = "http://files.stimulsoft.com/images/about.png";
    userButton.action = function () { alert("My Button Event"); }

    var toolbarTable = jsMvcViewer1.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>
Please place this code after the MvcViewer component.

Thank you.