Guest User

Untitled

a guest
Jan 27th, 2016
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.52 KB | None | 0 0
  1. <?php
  2. /**
  3. * PHP Grid Component
  4. *
  5. * @author Abu Ghufran <gridphp@gmail.com> - http://www.phpgrid.org
  6. * @version 1.5.2
  7. * @license: see license.txt included in package
  8. */
  9.  
  10. // include db config
  11. include_once("../../config.php");
  12.  
  13. // include and create object
  14. include(PHPGRID_LIBPATH."inc/jqgrid_dist.php");
  15.  
  16. $g = new jqgrid();
  17.  
  18. $grid["caption"] = "Client Data"; // caption of grid
  19. $grid["autowidth"] = true; // expand grid to screen width
  20. $grid["multiselect"] = false; // allow you to multi-select through checkboxes
  21. $grid["reloadedit"] = true;
  22.  
  23. $grid["loadComplete"] = "function(ids) { grid_onload(ids); }";
  24.  
  25. $g->set_options($grid);
  26.  
  27. $g->set_actions(array(
  28. "add"=>false, // allow/disallow add
  29. "edit"=>true, // allow/disallow edit
  30. "delete"=>true, // allow/disallow delete
  31. "rowactions"=>true, // show/hide row wise edit/del/save option
  32. "autofilter" => true, // show/hide autofilter for search
  33. "search" => "advance" // show single/multi field search condition (e.g. simple or advance)
  34. )
  35. );
  36.  
  37. // this db table will be used for add,edit,delete
  38. $g->table = "clients";
  39.  
  40.  
  41. $col = array();
  42. $col["title"] = "Id";
  43. $col["name"] = "client_id";
  44. $col["width"] = "20";
  45. $col["editable"] = true;
  46. $cols[] = $col;
  47.  
  48. $col = array();
  49. $col["title"] = "Name";
  50. $col["name"] = "name";
  51. $col["editable"] = true;
  52. $col["width"] = "80";
  53. $cols[] = $col;
  54.  
  55. $col = array();
  56. $col["title"] = "Gender";
  57. $col["name"] = "gender";
  58. $col["width"] = "30";
  59. $col["editable"] = true;
  60. $cols[] = $col;
  61.  
  62. $col = array();
  63. $col["title"] = "Company";
  64. $col["name"] = "company";
  65. $col["editable"] = true;
  66. $col["edittype"] = "textarea";
  67. $col["editoptions"] = array("rows"=>2, "cols"=>20);
  68. $cols[] = $col;
  69.  
  70. $g->set_columns($cols);
  71.  
  72. // generate grid output, with unique grid name as 'list1'
  73. $out = $g->render("list1");
  74. ?>
  75. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  76. <html>
  77. <head>
  78. <link rel="stylesheet" type="text/css" media="screen" href="../../lib/js/themes/redmond/jquery-ui.custom.css"></link>
  79. <link rel="stylesheet" type="text/css" media="screen" href="../../lib/js/jqgrid/css/ui.jqgrid.css"></link>
  80.  
  81. <script src="../../lib/js/jquery.min.js" type="text/javascript"></script>
  82. <script src="../../lib/js/jqgrid/js/i18n/grid.locale-en.js" type="text/javascript"></script>
  83. <script src="../../lib/js/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>
  84. <script src="../../lib/js/themes/jquery-ui.custom.min.js" type="text/javascript"></script>
  85. </head>
  86. <body>
  87. <script>
  88. function grid_onload(ids)
  89. {
  90. if(ids.rows)
  91. jQuery.each(ids.rows,function(i)
  92. {
  93. // if gender = male and client_id > 10
  94. if (this.gender.toLowerCase() == 'male' && parseInt(this.client_id) > 10)
  95. {
  96. // highlight row
  97. jQuery('#list1 tr.jqgrow:eq('+i+')').css('background-image','inherit').css({'background-color':'#FBEC88', 'color':'red'});
  98. }
  99.  
  100. // if clientId between 1 & 5, format cell. see 'aria-describedby=list1_client_id' is 'gridid_colname' convention to identify cell.
  101. if (parseInt(this.client_id) > 1 && parseInt(this.client_id) < 5)
  102. {
  103. // highlight cell
  104. jQuery('#list1 tr.jqgrow:eq('+i+')').css('background-image','inherit');
  105. jQuery('#list1 tr.jqgrow:eq('+i+') td[aria-describedby=list1_client_id]').css('background','inherit').css({'background-color':'#FBEC88', 'color':'red'});
  106. }
  107. });
  108. }
  109. </script>
  110. <div style="margin:10px">
  111. <br>
  112. <?php echo $out?>
  113. </div>
  114. </body>
  115. </html>
Add Comment
Please, Sign In to add comment