Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Q) How to apply more advanced conditional formatting?
- You can set onload event in PHP code, and enable 'reloadedit' option
- // set js onload event
- $e["js_on_load_complete"] = "grid_onload";
- $g->set_events($e);
- // required to format rows after editing
- $opt["reloadedit"] = true;
- ...
- $g->set_options($opt);
- Then in HTML code, you can have custom conditional logic in javascript handler.
- In this code, list1 is grid id. You can also use php's equivalent '$g->id' to reference it.
- <script>
- function grid_onload(ids)
- {
- if(ids.rows)
- jQuery.each(ids.rows,function(i)
- {
- // if col1 = yes and col2 = n/a, format row
- if (this.col1.toLowerCase() == 'yes' && this.col2.toLowerCase() == 'n/a')
- {
- // highlight row
- jQuery('#list1 tr.jqgrow:eq('+i+')').css('background-image','inherit').css({'background-color':'#FBEC88', 'color':'red'});
- }
- // if col3 = 1, format cell. 'aria-describedby=list1_col3' is 'gridid_colname' convention to identify cell.
- if (parseInt(this.col3) == 1)
- {
- // highlight cell
- jQuery('#list1 tr.jqgrow:eq('+i+')').css('background-image','inherit');
- jQuery('#list1 tr.jqgrow:eq('+i+') td[aria-describedby=list1_col3]').css('background','inherit').css({'background-color':'#FBEC88', 'color':'red'});
- }
- });
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement