* Please note this feature is not available in Lite and Basic versions.
Conditional formatting example using set_conditional_format() method.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | // Always include namespace and conf.php on TOP of the script. use phpCtrl\C_DataGrid; require_once("/path/to/conf.php"); $dg = new C_DataGrid("SELECT * FROM orders", "orderNumber", "orders"); //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"))); $dg->set_multiselect(true); $dg -> display(); |
Note:
For even more complex conditions, please refer to row level permission example by using set_grid_property() and add_event() method.