How to call Save function programmatically in designer?

Stimulsoft Reports.JS discussion
Post Reply
titanotam
Posts: 12
Joined: Thu Jun 29, 2017 6:22 am

How to call Save function programmatically in designer?

Post by titanotam »

Hi,

My report designer has these options:

Code: Select all

this.options.toolbar.showFileMenu = false;
this.options.toolbar.showSaveButton = false;
... and I create a custom Save button but don't know how to call the save report function programmatically.

Someone please help me :)

Thanks
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: How to call Save function programmatically in designer?

Post by Alex K. »

Hello,

You can use the following code:

Code: Select all

var designer = new Stimulsoft.Designer.StiDesigner(options, "StiDesigner", false);
          var customButton = document.getElementById("customButton");
          customButton.onclick = function () {
                designer.jsObject.SendCommandSaveReport();
            }
Thank you.
titanotam
Posts: 12
Joined: Thu Jun 29, 2017 6:22 am

Re: How to call Save function programmatically in designer?

Post by titanotam »

Aleksey wrote:Hello,

You can use the following code:

Code: Select all

var designer = new Stimulsoft.Designer.StiDesigner(options, "StiDesigner", false);
          var customButton = document.getElementById("customButton");
          customButton.onclick = function () {
                designer.jsObject.SendCommandSaveReport();
            }
Thank you.
Nice! Thank a lot ;)
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: How to call Save function programmatically in designer?

Post by Alex K. »

Hello

We are always glad to help you!
Please let us know if you need any additional help.

Thank you.
fridaystreet
Posts: 20
Joined: Thu Jun 08, 2023 11:40 pm

Re: How to call Save function programmatically in designer?

Post by fridaystreet »

Hi,

trying to do this but we get the error

Cannot set properties of undefined (setting 'reportIsModified')

Any ideas? do we need to pass something to the command?

Cheers
fridaystreet
Posts: 20
Joined: Thu Jun 08, 2023 11:40 pm

Re: How to call Save function programmatically in designer?

Post by fridaystreet »

bit further debugging and looks like options inside the designer object is undefined

error is caused by options not being defined at 'this.options.reportIsModified = !1'

stimulsoft.designer.js

Code: Select all

.SendCommandSaveReport = function(e, t) {
        var o, i, a, o;
        this.options.reportIsModified = !1,
        this.options.haveSaveEvent ? (o = {
            command: "SaveReport",
            reportFile: this.options.report.properties.reportFile,
            isNewReport: e,
            autoSave: t
        },
Last edited by fridaystreet on Wed Feb 07, 2024 3:04 am, edited 3 times in total.
fridaystreet
Posts: 20
Joined: Thu Jun 08, 2023 11:40 pm

Re: How to call Save function programmatically in designer?

Post by fridaystreet »

this is how we are generating the designer. at which point report has already been generated before it is assigned via 'newDesigner.report = report'

Code: Select all

const options = new window.Stimulsoft.Designer.StiDesignerOptions()
    options.Height = '100%'
    options.Width = '100%'
    options.appearance.allowChangeWindowTitle = false
    options.appearance.zoom = 'PageHeight'
    options.appearance.showSaveDialog = false
    options.appearance.fullScreenMode = true
    options.toolbar.showSaveButton = false
    options.toolbar.showFileMenuNewReport = true
    options.toolbar.showFileMenuNewDashboard = false
    options.toolbar.showFileMenuNew = true
    options.toolbar.showNewDashboardButton = false
    options.toolbar.showFileMenuOpen = true
    options.toolbar.showFileMenuClose = false
    options.toolbar.showFileMenuSaveAs = true
    options.toolbar.showFileMenuSave = false

    if (dashboardMode) {
      options.toolbar.showFileMenuNewDashboard = true
      options.toolbar.showFileMenuNewReport = false
      options.toolbar.showNewDashboardButton = true
      options.toolbar.showNewPageButton = false
      options.toolbar.showFileMenuReportSetup = false
      options.bands.showReportTitleBand = false
      options.bands.showReportSummaryBand = false
      options.bands.showPageHeaderBand = false
      options.bands.showPageFooterBand = false
      options.bands.showTableOfContents = false
    }

    for (const option in savedOptions) {
      options[option] = {
        ...options[option],
        ...savedOptions[option]
      }
    }

    const newDesigner = new window.Stimulsoft.Designer.StiDesigner(options, "StiDesigner", false)
    newDesigner.onSaveReport = onSaveReport
    newDesigner.onBeginProcessData = onBeginProcessData
    newDesigner.onExit = onExit
    newDesigner.report = report
    
    
    
Lech Kulikowski
Posts: 6247
Joined: Tue Mar 20, 2018 5:34 am

Re: How to call Save function programmatically in designer?

Post by Lech Kulikowski »

Hello,

Please send us a sample project that reproduces the issue for analysis.

Thank you.
Post Reply