Conditional Formatting
Conditional Formatting
With conditional formatting, you can specify the CSS of rows or columns based on data in it. When specifying class name you must declare the css class in your document before usage. (refer example: conditional-format.php)
// conditional css formatting of rows
$f = array();
$f["column"] = "name"; // exact column name, as defined above in set_columns or sql field name
$f["op"] = "cn"; // cn - contains, eq - equals
$f["value"] = "Ana";
$f["class"] = "focus-row"; // css class name
$f_conditions[] = $f;
$f = array();
$f["column"] = "invdate";
$f["op"] = "eq";
$f["value"] = "2007-10-04";
$f["class"] = "focus-row-red";
$f_conditions[] = $f;
// apply style on target column, if defined cellclass OR cellcss
$f = array();
$f["column"] = "id";
$f["op"] = "=";
$f["value"] = "7";
$f["cellclass"] = "focus-cell";
$f["target"] = "name";
$f_conditions[] = $f;
If nothing set in 'op' and 'value', it will set column formatting for all cell
$f = array();
$f["column"] = "invdate";
$f["css"] = "'background-color':'#FBEC88', 'color':'black'";
$f_conditions[] = $f;
Finally, you need to call set_conditional_css
of grid object to enable formatting.
$g->set_conditional_css($f_conditions);
Refer demos/appearance/conditional-format.php for reference.
Resources
- Sample Code
- See Live Demo
- You can check this demo in archive
demos/appearance/conditional-format.php