Page 1 of 1

Sorting by condition or BeforePrint event

Posted: Fri Feb 13, 2015 6:36 pm
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!

Re: Sorting by condition or BeforePrint event

Posted: Tue Feb 17, 2015 5:46 am
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.

Re: Sorting by condition or BeforePrint event

Posted: Wed Feb 18, 2015 4:29 pm
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?

Re: Sorting by condition or BeforePrint event

Posted: Thu Feb 19, 2015 6:03 am
by Alex K.
Hello,

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

Thank you.

Re: Sorting by condition or BeforePrint event

Posted: Thu Feb 19, 2015 11:49 am
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!

Re: Sorting by condition or BeforePrint event

Posted: Thu Feb 19, 2015 12:12 pm
by Alex K.
Hello,

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

Thank you.