How to build a generic report
How to build a generic report
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.
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.
Re: How to build a generic report
Hello,
You can pass parameters to the report in any action of the viewer. For example GetReportSnapshot:
or:
name and id - is a POST parameters
You can use the values of these parameters in report expressions and SQL queries.
Thank you.
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);
}
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);
}
You can use the values of these parameters in report expressions and SQL queries.
Thank you.
Re: How to build a generic report
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?
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?
Re: How to build a generic report
Hello.
Maybe we don't understand something.
Could you describe your issue more detailed?
Thank you.
Maybe we don't understand something.
Could you describe your issue more detailed?
Thank you.
Re: How to build a generic report
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.
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.
Re: How to build a generic report
Hello.
You could use parameters and variables in SQL queries.
Please, read the Dynamic SQL queries article on our blog.
Thank you.
You could use parameters and variables in SQL queries.
Please, read the Dynamic SQL queries article on our blog.
Thank you.
Re: How to build a generic report
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);
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);
Re: How to build a generic report
Hello,
Sorry, maybe we did not exactly understand your question.
Could you explain your issue in more details?
Thank you.
Sorry, maybe we did not exactly understand your question.
Could you explain your issue in more details?
Thank you.
Re: How to build a generic report
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.
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.
Re: How to build a generic report
Hello.
You could use RegData method and register your DataSet in the report.
Thank you.
You could use RegData method and register your DataSet in the report.
Thank you.