Conditional formatting

Discussion in 'Professional Support' started by nofc_fro, Aug 7, 2018.

  1. nofc_fro

    nofc_fro Member

    Level: Professional
    Hi, is it possible to have a conditional formatting?
    For example, in an "MyList" list with this field: ID, Name, Age , I want to color the age:
    green [0,30],
    yellow [31,60],
    red [61,100].
     
  2. troester

    troester Well-Known Member Staff Member

    Level: Standard
    You can add a calc element returning a CSS class name (can be any string, assuming colgreen in the example), set this element to "Use as row class" in List view settings.
    Then add custom CSS, e.g.
    #listform_$c .fabrikForm tr.colgreen td.your-table___element {color:green;}
     
    cheesegrits likes this.
  3. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Professional
    And the calc element would look something like ...

    Code (Text):

    $myAge = (int)'{mylist___age_raw}';
    if ($myAge <= 30) {
       return 'colgreen';
    }
    else if ($age <= 60) {
       return 'colyellow';
    }
    else {
       return 'colred';
    }
     
    Replace mylist___age_raw with the full element name of your age element, but keep the _raw suffix.

    -- hugh
     

Share This Page