Conditional Formatting

(4 posts) (3 voices)
  1. Is myDBR capable of doing conditional formatting? For example I have a column that calculates a percent, is it possible to style the background for that cell red if the value is below 70%, yellow if between 70% and 80%, green if above, etc?

  2. myDBR Team, Key Master

    Yes,
    there is a couple of ways of doing this. You can use 'dbr.purehtml' directly inside the column to add necessary css. However, the cleanest solution is to use a combination of row- and columnstyles with css like this:

    /* We'll define the style we like to use */
    select 'dbr.css', 'tr.red td.colorme { background-color: red }';
    select 'dbr.css', 'tr.blue td.colorme { background-color: blue }'; /* Defined fn_value_to_style-function will determine the colors used and will produce tr class 'red' or 'blue' */
    select 'dbr.rowclass', 3; /* We'll apply the css only to column 2 */
    select 'dbr.colclass', 2, 'colorme'; /* Do not need to show the style column */
    select 'dbr.hidecolumns', 1; /* Keep the actual qeueries clean for easy reading */
    select name, value, fn_value_to_style( value )
    from mytable;

    If you use same styles in many reports put the css in userstyle.css.

    --
    myDBR Team

  3. se-eric, Blocked

    Having some trouble with this.

    dbr.hidecolumns has an attribute of 1, but it looks like the style column is #3. why is this?

    Why is the attribute on dbr.rowclass 3?

    Thanks.

  4. myDBR Team, Key Master

    dbr.hidecolumns has an attribute of 1, but it looks like the style column is #3. why is this?

    dbr.hidecolumns's parameter is the number of columns from right to be hidden.

    Why is the attribute on dbr.rowclass 3?

    dbr.rowclass's parameter is the number of the column which contains the rowclass.

    See the documentation for more information.

    --
    myDBR Team


Reply

You must log in to post.