As usual, the SDK mentions the possibility of showing report fields in colour, but doesn't give the full explanation. You can change the font and/or font color of a specific report column, as well as determine its background color. This can be defined directly in the report, or indirectly, by designating another report column whose value determines the font or color. For example, use the Font Color Def. Column to specify the Col. Number of the report column whose value sets the font color. If the designated report column is hidden, that column must have a value in the Sort Priority column.
This is about 90% of the story. Ignoring the final sentence for a moment, the way that I discovered how to use colours was to define a column that checks a condition and returns a value (e.g. ORDERS.CURDATE < SQL.DATE8 ? 0 : 3) then one uses this column as written above. With regard to the returned value, 0 is 'no colour' and 3 is red. The table HTMLCOLORS lists the various colour available and one can add more if necessary. One quickly discovers that hiding this column causes the target column not to be coloured. So I was taught that one displays the column in the report then creates a display format (right click on the menu option for the report) that hides the column. Not perfect, but it works.
I discovered an easier way to achieve the desired result; this may not work in versions prior to 21. One defines the condition column as before and assigns it a value in the Sort Priority column (normally 9 or 99). One runs the report: the column that is to appear coloured does so, but the condition column also appears. Now hide the condition column and run the report: the first column is still coloured whilst the condition column does not appear. There is no need to create a display format then hide the condition column.
The value of the sort priority is irrelevant (although it has to be higher than anything in the report otherwise it is liable to affect the display order of the lines) but it has to be there. As far as I can see, having a sort priority is a type of 'escape clause' for the report generator; it knows that it has to perform some magic if there is a sort priority and the column number appears somewhere in the HTML definitions sub-form.
No comments:
Post a Comment