How to sort properly from C#
How to sort properly from C#
Hello Stimulsoft Team,
Since I haven't found it in samples on github I'll ask this question here. Let's assume I have a simple report where I parametrize it completely from C#. That's how we do it because some reports are automatically generated without any UI overnight. The moment I want to compile a report I need to set sorting. What is the proper way I should do it? Should I find databand and set its sort property or is there any other way?
Thanks in advance
Since I haven't found it in samples on github I'll ask this question here. Let's assume I have a simple report where I parametrize it completely from C#. That's how we do it because some reports are automatically generated without any UI overnight. The moment I want to compile a report I need to set sorting. What is the proper way I should do it? Should I find databand and set its sort property or is there any other way?
Thanks in advance
Re: How to sort properly from C#
Hi Scoroop,
Yes, that is possible. Please check the following topic:
viewtopic.php?&t=563
Thank you,
Edward
Yes, that is possible. Please check the following topic:
viewtopic.php?&t=563
Thank you,
Edward
Re: How to sort properly from C#
I have a problem that report never gets into the prerender event handler. What are prerequisites so that it gets called?
-
- Posts: 7345
- Joined: Tue Mar 20, 2018 5:34 am
Re: How to sort properly from C#
Hello,
You can add necessary sorting for the DataBand in your code when adding the band to the report, without using events.
Thank you.
You can add necessary sorting for the DataBand in your code when adding the band to the report, without using events.
Thank you.
Re: How to sort properly from C#
Good tip - actually we do have one report that is generated completely from C# code including StiReport. And in this one sorting worked, but those which use StiReport loaded from mrt file and already do have databand - I can't get it work. I suppose in such case there must be some method that is called when databand is added. Perhaps I could call it myself when setting sort property?
Re: How to sort properly from C#
anyone? 

-
- Posts: 7345
- Joined: Tue Mar 20, 2018 5:34 am
Re: How to sort properly from C#
Hello,
You can add sorting for mrt file also:
Thank you.
You can add sorting for mrt file also:
Code: Select all
report.Load("report.mrt");
var dataBand = report.GetComponentByName("DataBandName") as StiDataBand;
dataBand.Sort = new string[2] { "ASC", "Name"};
Re: How to sort properly from C#
That's basically my case. The point is sorting never happens. Therefore I started exploring options like setting Sort property in event handler or calling some method afterwards. Still no solution for me 

-
- Posts: 7345
- Joined: Tue Mar 20, 2018 5:34 am
Re: How to sort properly from C#
Hello,
Please send us a sample report or project which reproduces the issue for analysis.
Thank you.
Please send us a sample report or project which reproduces the issue for analysis.
Thank you.