set_conditional_format() *

* Please note this feature is not available in Lite and Basic versions.

  • Parameters:
    • $col_name: column name
    • $type: CELL or ROW
    • $formatoptions: array that stores condition and css style options
  • Description:
    • Format a cell based on the specified condition. CELL formats the a single cell. ROW formats the entire row.
       

      $formatoption is the most important parameter which itself is an array contains three elements:

      • condition,
      • value,
      • css.
       

      The elements are described in details as the following:

      The first parameter, condition, has the following available value.

      eq: Equals
      ne: Not Equals
      lt: Less than
      le: Less than or Equal
      gt: Greater than
      ge: Greater than or Equal
      cn: Contains
      nc: Does not Contain
      bw: Begins With
      bn: Not Begins With
      ew: Ends With
      en: Not Ends With

      The second parameter, value, is the comparing value in the right operand.

      css parameter in $formattoptions is an array collection that contains css style element for current cell or row.

  • Example:
1
2
3
4
5
6
7
8
9
10
11
12
13
//Format a cell based on the specified condition
$dg->set_conditional_format("orderNumber","CELL",array("condition"=>"eq",
                                                      "value"=>"10107",
                                                      "css"=> array("color"=>"#ffffff","background-color"=>"green")));

$dg->set_conditional_format("customerNumber","CELL",array("condition"=>"eq",
                                                  "value"=>"141",
                                                  "css"=> array("color"=>"red","background-color"=>"#DCDCDC")));

// Format a row based on the specified condition
$dg->set_conditional_format("comments","ROW",array("condition"=>"cn",
                                                  "value"=>"request",
                                                  "css"=>array("color"=>"white","background-color"=>"#4297D7")));

No related content found.

Tags: