Expression in before render event to order data

Stimulsoft Reports.NET discussion
Post Reply
rafael.custodio
Posts: 31
Joined: Thu May 30, 2019 1:01 pm

Expression in before render event to order data

Post by rafael.custodio »

Hi !! I´m trying to order some data in a report using the expression below in the before render event of a DataBand but it´s not working.

if DataBand.Date <= (01/03/2019){
DataBand.Sort = new string[] {"ASC","Clients.Name"};
}else{
DataBand.Sort = new string[] {"ASC","Clients.Date"};
}

Any thoughts ??
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: Expression in before render event to order data

Post by Lech Kulikowski »

Hello,

Should be:
DataBand.Sort = new string[] {"ASC","Name"};
}else{
DataBand.Sort = new string[] {"ASC","Date"};
}

Thank you.
rafael.custodio
Posts: 31
Joined: Thu May 30, 2019 1:01 pm

Re: Expression in before render event to order data

Post by rafael.custodio »

Hi Lech !! Thanks for replying, I tried and still not working, the order is not applied to the data band. I even tried just the expression below to check and it didn't work.

DataInfoAlumnoBr.Sort = new string[] {"ASC","Nombre"};

Also, I'm getting the error below:
Capturar.JPG
Capturar.JPG (29.94 KiB) Viewed 2201 times
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: Expression in before render event to order data

Post by Lech Kulikowski »

Hello,

Due to the error, you try to compare different types - DateTime and Integer.
Please send us a sample report with test data which reproduces the issue for analysis.

Thank you.
rafael.custodio
Posts: 31
Joined: Thu May 30, 2019 1:01 pm

Re: Expression in before render event to order data

Post by rafael.custodio »

Here are the sample report and data.
Attachments
Lista_de_alunos_20190918_151300.XML
(762.58 KiB) Downloaded 124 times
Relação de Alunos OrdenacaoPallas.mrt
(42.5 KiB) Downloaded 127 times
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: Expression in before render event to order data

Post by Lech Kulikowski »

Hello,

Column FechaIncorporacionCentro is DateTime, should be:
if (InfoAlumnoBr.FechaIncorporacionCentro <= DateSerial(2019,01,03)){
...

Thank you.
rafael.custodio
Posts: 31
Joined: Thu May 30, 2019 1:01 pm

Re: Expression in before render event to order data

Post by rafael.custodio »

Hi Lech !! thanks for replying, the error is gone but the expression still not ordering the results.

if(InfoAlumnoBr.FechaIncorporacionCentro <= DateSerial(2019,01,03)){
DataInfoAlumnoBr.Sort = new string[] {"ASC","Nombre"};
}else{
DataInfoAlumnoBr.Sort = new string[] {"ASC","FechaIncorporacionCentro"};
}
Capturar.JPG
Capturar.JPG (72.07 KiB) Viewed 2161 times
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: Expression in before render event to order data

Post by Lech Kulikowski »

Hello,

The logic of that code is wrong. You try to change sorting for each row of that data. Which value should be used in that expression:
InfoAlumnoBr.FechaIncorporacionCentro <= 01/03/2019

Thank you.
Attachments
Annotation 2019-09-22 180246.jpg
Annotation 2019-09-22 180246.jpg (385.56 KiB) Viewed 2136 times
Post Reply