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: https://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.
Filed under: APEX Tagged: APEX, CSS, tips-&-tricks
