How to build a generic report

Stimulsoft Reports.WEB discussion
beginner
Posts: 36
Joined: Thu Jun 18, 2015 5:01 am

How to build a generic report

Post by beginner »

I'd like to use Stimulsoft Reports in my ASP.NET MVC application. In my scenario, user will fill some fields and I will show him or her a report. User's values are used to limit the query and they're mostly used in a where clause, and a few of them are used for sorting and grouping.

Unfortunately, Stimulsoft is not able to pass parameters in the get snapshot method.

I'll be grateful if you could guide me to the best and easiest way to design this reports.
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Re: How to build a generic report

Post by Vladimir »

Hello,

You can pass parameters to the report in any action of the viewer. For example GetReportSnapshot:

Code: Select all

public ActionResult GetReportSnapshot()
{
    StiReport report = new StiRepot();
    report.Load("repor.mrt");
    report["ParamName1"] = "ParamValue";
    report["ParamName2"] = 123;

    return StiMvcViewer.GetReportSnapshotResult(report);
}
or:

Code: Select all

public ActionResult GetReportSnapshot(string name, int id)
{
    StiReport report = new StiRepot();
    report.Load("repor.mrt");
    report["ParamName1"] = name;
    report["ParamName2"] = id;

    return StiMvcViewer.GetReportSnapshotResult(report);
}
name and id - is a POST parameters


You can use the values of these parameters in report expressions and SQL queries.

Thank you.
beginner
Posts: 36
Joined: Thu Jun 18, 2015 5:01 am

Re: How to build a generic report

Post by beginner »

Thanks for your replay Vladimir,
Parameters that I want to pass are much higher, maybe about 20. This way I should have different report files and get snapshot methods for each report.

Do I have any better option?
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: How to build a generic report

Post by HighAley »

Hello.

Maybe we don't understand something.
Could you describe your issue more detailed?

Thank you.
beginner
Posts: 36
Joined: Thu Jun 18, 2015 5:01 am

Re: How to build a generic report

Post by beginner »

I have another similar question,

It seems that the report uses its own Data source to fetch the data from DB, right? Can I change that, I'd like it to use my filtered query and data source. I have a lot of conditions that use can play with, I don't like to define a variable for each one of them, it'd be much easier if I could use my own query and limit the query on server-side. Is that possible?

Thanks for your advance Aleksey.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: How to build a generic report

Post by HighAley »

Hello.

You could use parameters and variables in SQL queries.
Please, read the Dynamic SQL queries article on our blog.

Thank you.
beginner
Posts: 36
Joined: Thu Jun 18, 2015 5:01 am

Re: How to build a generic report

Post by beginner »

Thanks for your replay Aleksey,

I was looking to filter data in my own code. I mean what is the reason of `Regdata` then?

Is there anyway that I can use something like this:

var data = from g in goods
.Where(x => x.CGoodCode.Equals("234"))
select g;
report.RegData("DataSource1", data);
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

Re: How to build a generic report

Post by Ivan »

Hello,

Sorry, maybe we did not exactly understand your question.
Could you explain your issue in more details?

Thank you.
beginner
Posts: 36
Joined: Thu Jun 18, 2015 5:01 am

Re: How to build a generic report

Post by beginner »

Hi Ivan,

I'm looking for a way to filter data in my own code, because I have so many variables, defining all of them in the report is a little hard. On the other hand, if I was able to filter the data in my own code and in my MVC app and send that data to the report, things would be much easier.

Imagine a scenario where I receive a relatively big form from user, I'll build the data with all of the where and order clauses and send it to the report... .

Thanks for your attention.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: How to build a generic report

Post by HighAley »

Hello.

You could use RegData method and register your DataSet in the report.

Thank you.
Post Reply