Show greyscale icon as red
I have an editable tabular form using APEX’s old greyscale edit link icons:
The users complained that they currently have to click each link to drill down to the detail records to find and fix any errors; they wanted the screen to indicate which detail records were already fine and which ones needed attention.
Since screen real-estate is limited here, I wanted to indicate the problems by showing a red edit link instead of the default greyscale one; since this application is using an old theme I didn’t feel like converting it to use Font Awesome (not yet, at least) and neither did I want to create a whole new image and upload it. Instead, I tried a CSS trick to convert the greyscale image to a red shade.
I used this informative post to work out what I needed: http://css-tricks.com/color-filters-can-turn-your-gray-skies-blue/
WARNING: Unfortunately this trick does NOT work in IE (tested in IE11). Blast.
Firstly, I added a column to the underlying query that determines if the error needs to be indicated or not:
select ..., case when {error condition} then 'btnerr' end as year1_err from mytable...
I set the new column type to Hidden Column.
The link column is rendered using a Link-type column, with Link Text set to:
<img src="#IMAGE_PREFIX#e2.gif" alt="">
I changed this to:
<img src="#IMAGE_PREFIX#e2.gif" alt="" class="#YEAR1_ERR#">
What this does is if there is an error for a particular record, the class "btnerr"
is added to the img tag. Rows with no error will simply have class=""
which does nothing.
Now, to make the greyscale image show up as red, I need to add an SVG filter to the HTML Header in the page:
<svg style="display:none"><defs> <filter id="redshader"> <feColorMatrix type="matrix" values="0.7 0.7 0.7 0 0 0.2 0.2 0.2 0 0 0.2 0.2 0.2 0 0 0 0 0 1 0"/> </filter> </defs></svg>
I made up the values for the R G B lines with some trial and error. The filter is applied to the buttons with the btnerr class with this CSS in the Inline CSS property of the page:
img.btnerr {filter:url(#redshader);}
The result is quite effective:
But, as I noted earlier, this solution does not work in IE, so that’s a big fail.
NOTE: if this application was using the Universal Theme I would simply apply a simple font color style to the icon since it would be using a font instead of an image icon.
ubuncent (@ubuncent)
3 July 2017 - 11:10 pm
Jeffrey, I am wondering how did you add the text fields showing in blue beneath the tabular form row, which used to show the sum of each column. Thanks,
Jeffrey Kemp
4 July 2017 - 8:45 am
Hi ubuncent, I have another classic report below the tabular form which generates the total items, plus some custom javascript to align the items horizontally and keep them updated as the user makes changes. There’s not enough room in a comment here to explain in more detail. The method used to generate the totals dynamically is described here: http://jeffkemponoracle.com/2016/04/05/declarative-tabular-form-dynamic-totals/