Page 1 of 1

Report parameters

Posted: Wed Aug 22, 2012 2:47 pm
by lloydk
How can I pass parameters into a report from JavaScript?

We have a custom reporting system and parameters are extracted from the report and placed in a grid. Eventually the parameters will be hidden (RequestFromUser = false) from the actual report viewer control.

What I want to do is basically control the report much the same way as the existing controls do.

Re: Report parameters

Posted: Thu Aug 23, 2012 11:23 am
by Vladimir
Hello,

Passing parameters to a report using Javascript is not provided. You can set the report parameters on the server side, passing them using the GET or POST requests.

Thank you.

Re: Report parameters

Posted: Thu Aug 23, 2012 12:06 pm
by lloydk
How do your controls do it then? It's doesn't seem to cause a postback, or does it?

If I did pass in the variables say as parameters to the page, how do I set them against the report and then run the report? Do I just do stim_report[var] = ...?

Currently I do something like this:

Code: Select all

            // Work out reports filename
            string filename = Path.Combine(path,report.Path);

            // Set up report viewer
            StiReport stim_report = new StiReport();

			stim_report.Load(filename);
			stim_report.Compile();

#if !DEBUG
            foreach(StiVariable v in stim_report.Dictionary.Variables.Items) v.RequestFromUser = false;
#endif

            webViewer.Report = stim_report;

Re: Report parameters

Posted: Fri Aug 24, 2012 11:50 am
by Vladimir
Hello,

You can set the parameters for the report as follows:

Code: Select all

StiReport stim_report = new StiReport();
stim_report.Load(filename);
stim_report.Compile();

stim_report["VarName1"] = value1;
stim_report["VarName2"] = value2;

stim_report.Render(false);
or:

Code: Select all

StiReport stim_report = new StiReport();
stim_report.Load(filename);

foreach(StiVariable v in stim_report.Dictionary.Variables)
{
    v.RequestFromUser = false;
    v.Value = somevalue;
}

stim_report.Compile();
stim_report.Render(false);
Thank you.