logo

Warning: The forum is now for consultation only. Please use GitHub Discussions to post any questions or comments.


Welcome Guest ! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
jysaghbini  
#1 Posted : Wednesday, April 29, 2015 8:57:33 AM(UTC)
jysaghbini

Rank: Member

Groups: Registered
Joined: 4/17/2015(UTC)
Posts: 17
Lebanon

Thanks: 1 times
Dear epf,

I received a request for a new type of report. I was wondering if it was doable in Seal Report.

Basically, besides standard filtering, the user has to input boundary values (Min and Max). Based on these values, all values in the report that are lower than Min value will be in red, and all values in the report that are higher than Max value will be in green. The rest will remain the same.

I know there is an option to modify the CSS of all the cells, with specific CSS related to negative values. But I am not sure I can use this feature in this case.

Regards,

Jean-Yves
epf  
#2 Posted : Wednesday, April 29, 2015 6:28:39 PM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 1,209
Switzerland

Thanks: 14 times
Was thanked: 206 time(s) in 199 post(s)
Yes it is possible but you will have to dive a little bit in C# and the report model...

Here is how to proceed:
First create 2 restrictions based on a numeric field in your model, set them to
Operator = ValueOnly
Rename them to Min and Max
Finally set the Operator Label to = and Set them at Prompt at Execution

In the restriction text, you have to master the SQL generated so it will (or not) impact the actual SQL restrictions.
e.g. If you do not want that to interfere with your filter, you could have something which look like
([Min ?] = [Max = ?] OR 1 = 1) which gives always true, but defines your 2 restrictions.

Then you will have to update the view template displaying the model.
Select your view (the one displaying the model), set 'Use custom template text' to true,
then edit the template:

at the end of the text, when displaying the tbody of the Data Table, replace:
Code:
<td class='@className' style='@cell.CellCssStyle'>@Raw(cell.HTMLValue)</td>


by something like

Code:

string css = (cell.DoubleValue != null && cell.DoubleValue.Value < int.Parse(@ReportModel.Restrictions[0].Value1)  ? cell.CellCssStyle + ";color:green;" : cell.CellCssStyle);
css = (cell.DoubleValue != null && cell.DoubleValue.Value > int.Parse(@ReportModel.Restrictions[1].Value1)  ? cell.CellCssStyle + ";color:red;" : cell.CellCssStyle);
<td class='@className' style='@css'>@Raw(cell.HTMLValue)</td>



where cell.DoubleValue.Value is the value of the cell in numeric
ReportModel.Restrictions[0].Value1 is the string value1 of the first restriction of the report (we assume here it is Min), we just convert it into an int using int.Parse()

the Max should be in ReportModel.Restrictions[1].Value1

Let us know if you managed to do it...



thanks 1 user thanked epf for this useful post.
jysaghbini on 5/1/2015(UTC)
jysaghbini  
#3 Posted : Friday, May 1, 2015 8:47:14 PM(UTC)
jysaghbini

Rank: Member

Groups: Registered
Joined: 4/17/2015(UTC)
Posts: 17
Lebanon

Thanks: 1 times
Dear epf,

It worked out perfectly. Thank you.

I had to correct a small thing in your code. In the second code snippet, I had to change the following value:

string css = (cell.DoubleValue != null && cell.DoubleValue.Value < int.Parse(@ReportModel.Restrictions[0].Value1) ? cell.CellCssStyle + ";color:green;" : cell.CellCssStyle);
css = (cell.DoubleValue != null && cell.DoubleValue.Value > int.Parse(@ReportModel.Restrictions[1].Value1) ? cell.CellCssStyle + ";color:red;" : css);
<td class='@className' style='@css'>@Raw(cell.HTMLValue)</td>

Thanks a lot.

Jean-Yves
epf  
#4 Posted : Sunday, August 16, 2015 1:17:01 PM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 1,209
Switzerland

Thanks: 14 times
Was thanked: 206 time(s) in 199 post(s)
Update with the 1.8 version:
You can do it now without editing the template but by using the 'Cell Script' property of your report element in the model,
Check out the sample provided in 51-User input - Connection and threshold.srex

Note also the new restrictions properties: 'Custom enumerated list' and 'Use as parameter'
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.