Advertisement
Guest User

checkbox and excelview

a guest
Nov 2nd, 2015
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.29 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. // you can customize your own columns ...
  17.  
  18. $col = array();
  19. $col["title"] = "Id"; // caption of column
  20. $col["name"] = "id"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  21. $col["width"] = "10";
  22. $col["editable"] = true;
  23. $col["hidden"] = true;
  24. $cols[] = $col;
  25.  
  26. $col = array();
  27. $col["title"] = "Date";
  28. $col["name"] = "invdate";
  29. $col["width"] = "50";
  30. $col["editable"] = true; // this column is editable
  31. $col["editoptions"] = array("size"=>20, "defaultValue"=>"02/02/2013"); // with default display of textbox with size 20
  32. $col["editrules"] = array("required"=>true, "edithidden"=>true); // and is required
  33. $col["formatter"] = "date"; // format as date
  34. $col["formatoptions"] = array("srcformat"=>'Y-m-d',"newformat"=>'d/m/Y'); // http://docs.jquery.com/UI/Datepicker/formatDate
  35. $cols[] = $col;
  36.  
  37. $col = array();
  38. $col["title"] = "Client";
  39. $col["name"] = "name";
  40. $col["width"] = "100";
  41. $col["editable"] = false; // this column is not editable
  42. $col["align"] = "center"; // this column is not editable
  43. $col["search"] = false; // this column is not searchable
  44.  
  45. $cols[] = $col;
  46.  
  47. $col = array();
  48. $col["title"] = "Note";
  49. $col["name"] = "note";
  50. # $col["width"] = "300"; // not specifying width will expand to fill space
  51. $col["sortable"] = false; // this column is not sortable
  52. $col["search"] = false; // this column is not searchable
  53. $col["editable"] = true;
  54. $col["edittype"] = "textarea"; // render as textarea on edit
  55. $col["editoptions"] = array("rows"=>2, "cols"=>20); // with these attributes
  56. $cols[] = $col;
  57.  
  58. $col = array();
  59. $col["title"] = "Total";
  60. $col["name"] = "total";
  61. $col["width"] = "50";
  62. $col["editable"] = true;
  63. $col["formatter"] = "number";
  64.  
  65. // To mask password field, apply following attribs
  66. # $col["edittype"] = "password";
  67. # $col["formatter"] = "password";
  68.  
  69. // default render is textbox
  70. // $col["editoptions"] = array("value"=>'10');
  71.  
  72. // can be switched to select (dropdown)
  73. // $col["edittype"] = "select"; // render as select
  74. // $col["editoptions"] = array("value"=>'10:$10;20:$20;30:$30;40:$40;50:$50'); // with these values "key:value;key:value;key:value"
  75.  
  76. $cols[] = $col;
  77.  
  78. $col = array();
  79. $col["title"] = "Closed";
  80. $col["name"] = "closed";
  81. $col["width"] = "50";
  82.  
  83. $col["editable"] = true;
  84. $col["edittype"] = "checkbox"; // render as checkbox
  85. $col["editoptions"] = array("value"=>"1:0"); // with these values "checked_value:unchecked_value"
  86. $cols[] = $col;
  87.  
  88. $g = new jqgrid();
  89.  
  90. // $grid["url"] = ""; // your paramterized URL -- defaults to REQUEST_URI
  91. $grid["rowNum"] = 10; // by default 20
  92. $grid["sortname"] = 'id'; // by default sort grid by this field
  93. $grid["sortorder"] = "desc"; // ASC or DESC
  94. $grid["caption"] = "Invoice Data"; // caption of grid
  95. $grid["autowidth"] = true; // expand grid to screen width
  96. $grid["multiselect"] = true; // allow you to multi-select through checkboxes
  97. $grid["cellEdit"] = true; // allow you to multi-select through checkboxes
  98. $grid["form"]["position"] = "center";
  99. $g->set_options($grid);
  100.  
  101. $g->set_actions(array(
  102. "add"=>true, // allow/disallow add
  103. "edit"=>true, // allow/disallow edit
  104. "delete"=>true, // allow/disallow delete
  105. "view"=>true, // allow/disallow delete
  106. "rowactions"=>true, // show/hide row wise edit/del/save option
  107. "search" => "advance", // show single/multi field search condition (e.g. simple or advance)
  108. "showhidecolumns" => false
  109. )
  110. );
  111.  
  112. // you can provide custom SQL query to display data
  113. $g->select_command = "SELECT i.id, invdate , c.name,
  114. i.note, i.total, i.closed FROM invheader i
  115. INNER JOIN clients c ON c.client_id = i.client_id";
  116.  
  117. // you can provide custom SQL count query to display data
  118. $g->select_count = "SELECT count(*) as c FROM invheader i
  119. INNER JOIN clients c ON c.client_id = i.client_id";
  120.  
  121. // this db table will be used for add,edit,delete
  122. $g->table = "invheader";
  123.  
  124. // pass the cooked columns to grid
  125. $g->set_columns($cols);
  126.  
  127. // generate grid output, with unique grid name as 'list1'
  128. $out = $g->render("list1");
  129. ?>
  130. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  131. <html>
  132. <head>
  133. <link rel="stylesheet" type="text/css" media="screen" href="../../lib/js/themes/redmond/jquery-ui.custom.css"></link>
  134. <link rel="stylesheet" type="text/css" media="screen" href="../../lib/js/jqgrid/css/ui.jqgrid.css"></link>
  135. <script src="../../lib/js/jquery.min.js" type="text/javascript"></script>
  136. <script src="../../lib/js/jqgrid/js/i18n/grid.locale-en.js" type="text/javascript"></script>
  137. <script src="../../lib/js/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>
  138. <script src="../../lib/js/themes/jquery-ui.custom.min.js" type="text/javascript"></script>
  139. </head>
  140. <body>
  141.  
  142. <style>
  143. .ui-jqgrid tr.ui-row-ltr td.edit-cell {
  144. padding-top: 3px;
  145. padding-bottom: 3px;
  146. }
  147. .ui-jqgrid tr.jqgrow td {
  148. height: 25px;
  149. }
  150. </style>
  151.  
  152. <div style="margin:10px">
  153. <?php echo $out?>
  154. </div>
  155. </body>
  156. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement