Expression in before render event to order data

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

Expression in before render event to order data

Post by rafael.custodio » Tue Sep 10, 2019 5:26 pm

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: 1759
Joined: Tue Mar 20, 2018 5:34 am

Re: Expression in before render event to order data

Post by Lech Kulikowski » Wed Sep 11, 2019 8:39 pm

Hello,

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

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

Re: Expression in before render event to order data

Post by rafael.custodio » Fri Sep 13, 2019 12:03 pm

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 75 times
Lech Kulikowski
Posts: 1759
Joined: Tue Mar 20, 2018 5:34 am

Re: Expression in before render event to order data

Post by Lech Kulikowski » Fri Sep 13, 2019 3:00 pm

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: 15
Joined: Thu May 30, 2019 1:01 pm

Re: Expression in before render event to order data

Post by rafael.custodio » Wed Sep 18, 2019 3:23 pm

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

Re: Expression in before render event to order data

Post by Lech Kulikowski » Thu Sep 19, 2019 8:54 am

Hello,

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

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

Re: Expression in before render event to order data

Post by rafael.custodio » Thu Sep 19, 2019 11:42 am

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 35 times
Lech Kulikowski
Posts: 1759
Joined: Tue Mar 20, 2018 5:34 am

Re: Expression in before render event to order data

Post by Lech Kulikowski » Sun Sep 22, 2019 4:02 pm

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 10 times
Post Reply