Using reports events and variables doubt

Stimulsoft Reports.JS discussion
Post Reply
agodoo
Posts: 9
Joined: Tue May 22, 2018 10:56 pm

Using reports events and variables doubt

Post by agodoo »

Hello,
I have a report with one variable setted as "Request from user"; it is configured as a list of two values; so when I render the report, it opens the dialog and ask the user to select one of the values for the variable.

I need to export report by code only after the user has filled in the value for that variable, so I imagined to use report events.
My idea was to use onShowReport event and check the value of the variable to see if execute the export portion of code or not.
But I have an issue getting the current value of the variable.

Here is my code:

Code: Select all

   viewer.onShowReport = function (event) {

        var variable_vettore = report.dictionary.variables.getByName("Vettore");
        variable_vettore_txt = variable_vettore.value;

        if(variable_vettore_txt !== null && variable_vettore_txt !== '') {
        	// export code here
        	console.log('export');
        } else {
		// do nothing
		console.log('wait');
        }
    }
it never run the export code part also after the user has choosen the value for the variable and re-submitted the report clicking on the submit button on the variable dialog.

Where do I'm worng? Or there is a completly different approach to my idea?

With thanks,
Matteo
Lech Kulikowski
Posts: 6271
Joined: Tue Mar 20, 2018 5:34 am

Re: Using reports events and variables doubt

Post by Lech Kulikowski »

Hello,

Please try to use the RequestParameters option for the report. In this case, report will be rendered only after filling parameters.

Thank you.
Post Reply