Sorting by condition or BeforePrint event

Stimulsoft Reports.WEB discussion
Post Reply
Paulo Lemos
Posts: 19
Joined: Tue Jan 06, 2015 7:39 pm

Sorting by condition or BeforePrint event

Post by Paulo Lemos »

Hi there,

Is there a way to set the sorting property of a data band by a condition based on another property informed in a second Dictionary (query)?

Ex:

A report listing clients.Id, clients.Name and clients.PhoneNumber from the "clients" Dictionary, obviously. But I have a second Dictionary named "filter", with a single property of type int, called sortBy.

So, if filter.sortBy == 1, data band will sort by Id, sortBy == 2 data band will sort by name, and if sortBy == 3 it would sort by PhoneNumber.

I had solved this by another way, doing a switch/case orderBy in the query, on beforePrintReport event, and disabling any sorting of GroupHeaderBands, but I really would like to know if its possible of doing inside stimulsoft's, like using BeforePrint event on the data band or something like that.

Thanks in advance!
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Sorting by condition or BeforePrint event

Post by HighAley »

Hello.

You can set the Sort property in the Begin Render property.
How to set the Sort property you could read in the article from the Stimulsoft Knowledge Base.

Thank you.
Paulo Lemos
Posts: 19
Joined: Tue Jan 06, 2015 7:39 pm

Re: Sorting by condition or BeforePrint event

Post by Paulo Lemos »

Thanks Aleksey, but where should I put that C# code? I mean, from where should I access the BeginRender property like that?
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Sorting by condition or BeforePrint event

Post by Alex K. »

Hello,

You can use this code in the BeginRender or BeforePrint events.

Thank you.
Paulo Lemos
Posts: 19
Joined: Tue Jan 06, 2015 7:39 pm

Re: Sorting by condition or BeforePrint event

Post by Paulo Lemos »

I just needed to switch the "report." to "this.", because it didn't recognized my report name. But it worked. Thank you! That was very helpfull!
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Sorting by condition or BeforePrint event

Post by Alex K. »

Hello,

We are always glad to help you!
Let us know if you need any additional help.

Thank you.
Post Reply