Conditional format - compare two cells
Is there a way two compare two cells and highlight the cell which is bigger? Solution:
See the javascript used in demo http://phpgrid.com/example/row-level-permission-edit-condtion/. When condition is met, can do something like the following in the Javascript.
jQuery("#TABLENAME").jqGrid("setCell", row, col, value,{background:'#ff0000'});Complete code:
<?php// note this should not replace database role-based or user-based permissions.$onGridLoadComplete = <<<ONGRIDLOADCOMPLETEfunction(status, rowid){ var ids = jQuery("#orders").jqGrid('getDataIDs'); for (var i = 0; i < ids.length; i++) { var rowId = ids[i]; var rowData = jQuery('#orders').jqGrid ('getRowData', rowId); var requiredDate = new Date($("#orders").jqGrid("getCell", rowId, "requiredDate")); var shippedDate = new Date($("#orders").jqGrid("getCell", rowId, "shippedDate")); // compare two dates and set custom display in another field "status" if(requiredDate < shippedDate){ $("#orders").jqGrid("setCell", rowId, "status", '', {'background-color':'gold'}); } }}ONGRIDLOADCOMPLETE;$dg = new C_DataGrid("SELECT * FROM orders", "orderNumber", "orders");$dg->set_col_hidden('comments');$dg->add_event("jqGridLoadComplete", $onGridLoadComplete);$dg->enable_edit('INLINE', 'CRUD');$dg -> display();?>