0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Query Builder:Expression】Use icons in a Web report (HTML + CSS)

0
Last updated at Posted at 2024-07-24

Introduction

In the previous post, I talked about showing icons on a web report.
The icons were displayed in a column next to the related numbers column.

I would like to show to display the number and icon together in a column this time.
image.png

Base Query

Let's create a new report with Sharperlight publisher.
I had the report created before so make a clone of it this time.
Choose the existing report, right-click to show the popup menu and select Clone, once Sharperlight publisher is open.
image.png
It would create a clone of it with '2' at the end of its code.
image.png

Editing

Open the clone and go for its query definition, and let's start modifing the existing expression.
image.png
The number and icon need to be together in a cell so I use HTML Table tag this time.
The expression can be like this and don't forget the Data Type property should be HTML.
image.png

"<table class='StatusIconStyle'><tr>" +
Switch( True
,{%StockLeft} >= 100,"<td>"+Format( "#,##0" , {%StockLeft} )+"</td><td><img class='StatusIconStyleImg' src='{_System.Rest.URL}Image/?icode=StatusGreen'></img></td>"
,{%StockLeft} < 100 AND {%StockLeft} >= 30,	"<td>"+Format( "#,##0" , {%StockLeft} )+"</td><td><img class='StatusIconStyleImg' src='{_System.Rest.URL}Image/?icode=StatusYellow'></img></td>"
,"<td>"+Format( "#,##0" , {%StockLeft} )+"</td><td><img class='StatusIconStyleImg' src='{_System.Rest.URL}Image/?icode=StatusRed'></img></td>"
)
+ "</tr></table>"

Stocks Left can be hidden as its value is now displayed with the icon, also add description to the expression.
image.png

Preview

We can now preview it with Preview button. Preview doesn't show icons this time and display HTML table tags.
image.png

CSS

The HTML table tag and img tag each have a class.
Let's define the classes to CSS option of the report.
image.png
image.png

<style type="text/css">
.StatusIconStyle td {
	border:hidden !important;
	width: 30px !important;
	text-align: right !important;
}
.StatusIconStyleImg
{
	border:0px;
	display:inline;
	margin-top: 4px;
	margin-left: 10px;
    	width: 16px;
    	height: 16px;
}
</style>

Publishing the report

Save the query and save the web report.
Start Sharperlight service.
View the web report in your browser.
We shoud see the web report like this.
image.png

Conclusion

There are many Sharperlight expressions and we can create more attractive web reports with them.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?