Seal Report Forum
»
Report Edition
»
Reports
»
Highlight specific cells based on values
Rank: Member
Groups: Registered
Joined: 4/17/2015(UTC) Posts: 17 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
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 12/20/2013(UTC) Posts: 1,209 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].Value1Let us know if you managed to do it...
|
1 user thanked epf for this useful post.
|
|
|
Rank: Member
Groups: Registered
Joined: 4/17/2015(UTC) Posts: 17 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
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 12/20/2013(UTC) Posts: 1,209 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'
|
|
|
|
Seal Report Forum
»
Report Edition
»
Reports
»
Highlight specific cells based on values
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.