Report parameters

Stimulsoft Reports.WEB discussion
Post Reply
lloydk
Posts: 15
Joined: Fri Aug 10, 2012 2:41 pm

Report parameters

Post 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.
Attachments
snip.PNG
snip.PNG (147.95 KiB) Viewed 1490 times
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Re: Report parameters

Post 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.
lloydk
Posts: 15
Joined: Fri Aug 10, 2012 2:41 pm

Re: Report parameters

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

Re: Report parameters

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