Toolbar close button in Report viewer

Stimulsoft Reports.JS discussion
Post Reply
rodrigorodrigues
Posts: 11
Joined: Mon Aug 01, 2016 11:25 pm

Toolbar close button in Report viewer

Post by rodrigorodrigues »

I was looking on documentation for a button at toolbar to close the report itself, I didn't find!

Code: Select all

var options = new Stimulsoft.Viewer.StiViewerOptions();
        options.height = "100%";
        options.appearance.scrollbarsMode = true;
        options.toolbar.showDesignButton = true;
it was great if we should use like

Code: Select all

options.toolbar.showCloseButton = true;
is there any option to close the Report Viewer or how can I insert this feature?
peda
Posts: 39
Joined: Fri Feb 12, 2016 9:24 am

Re: Toolbar close button in Report viewer

Post by peda »

You can close with JS easy

Code: Select all

viewer.jsObject.CloseReport();
rodrigorodrigues
Posts: 11
Joined: Mon Aug 01, 2016 11:25 pm

Re: Toolbar close button in Report viewer

Post by rodrigorodrigues »

Thank you, this is the action to close, how to insert a button in toolbar? Into this button will insert this code, how to make a button appear on toolbar?
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Toolbar close button in Report viewer

Post by HighAley »

Hello.

You could use next code to add button on the toolbar.

Code: Select all

var userButton = jsStiWebViewer1.SmallButton("userButton", "My Button", "emptyImage"); // (name, captionText, imageName, toolTip, arrow, styleName);
userButton.image.src = "icon.png";
userButton.action = function () { alert("My Button Event"); }

var toolbarTable = jsStiWebViewer1.controls.toolbar.firstChild.firstChild;
var buttonsTable = toolbarTable.rows[0].firstChild.firstChild;
var userButtonCell = buttonsTable.rows[0].insertCell(0);
userButtonCell.className = "stiJsViewerClearAllStyles";
userButtonCell.appendChild(userButton);
Thank you.
rodrigorodrigues
Posts: 11
Joined: Mon Aug 01, 2016 11:25 pm

Re: Toolbar close button in Report viewer

Post by rodrigorodrigues »

peda wrote:You can close with JS easy

Code: Select all

viewer.jsObject.CloseReport();

The button is showing with HighAley code, but the function to close the report didn't work,

Code: Select all

viewer.jsObject.CloseReport()

Code: Select all

userButton.action = function () {
            viewer.jsObject.CloseReport();
        }

error : viewer.jsObject.CloseReport is not a function
The object jsObject exists on viewer instance but CloseReport doesn't exists on jsObject

I need to close the Report Viewer, actually, I think this button should be default
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Toolbar close button in Report viewer

Post by Alex K. »

Hello,

Please try to use the following code:

Code: Select all

userButton.action = function () {
        //if you want close only report in the viewer, use this code
        this.jsObject.controls.reportPanel.clear();
        this.jsObject.reportParams.pageNumber = 0;
        this.jsObject.reportParams.pagesCount = 0;
        this.jsObject.controls.toolbar.changeToolBarState();

        //if you want close viewer, use this code
        this.jsObject.controls.viewer.parentNode.removeChild(this.jsObject.controls.viewer);

        //if you want go to previews page, use this code
        history.back();
    }
Thank you.
lampsea12
Posts: 9
Joined: Fri Sep 16, 2016 8:50 am

Re: Toolbar close button in Report viewer

Post by lampsea12 »

How can i add a close button when use angularJS 1.x,
I can't implement jsStiWebViewer1!
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Toolbar close button in Report viewer

Post by HighAley »

Hello.

Sorry, we don't have special solution for the AngularJS.
Please, try to use the same code.

Thank you.
Post Reply