How to add custom button to mvc viewer toolbar?

Stimulsoft Reports.WEB discussion
Post Reply
hfirst
Posts: 25
Joined: Mon Apr 20, 2015 2:11 pm

How to add custom button to mvc viewer toolbar?

Post 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?
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

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

Post by HighAley »

Hello.

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

Thank you.
hfirst
Posts: 25
Joined: Mon Apr 20, 2015 2:11 pm

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

Post 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.
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

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

Post 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.
Post Reply