Advertisement
Guest User

Untitled

a guest
Jan 19th, 2016
913
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.89 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"] = "Group Headers"; // expand grid to screen width
  19. $grid["autowidth"] = true; // expand grid to screen width
  20. $grid["multiselect"] = false; // allow you to multi-select through checkboxes
  21. $grid["view_options"] = array("width"=>"500");
  22.  
  23. $g->set_options($grid);
  24.  
  25. $g->set_actions(array(
  26. "add"=>true, // allow/disallow add
  27. "edit"=>true, // allow/disallow edit
  28. "delete"=>true, // allow/disallow delete
  29. "view"=>true, // allow/disallow delete
  30. "rowactions"=>true, // show/hide row wise edit/del/save option
  31. "search" => "advance", // show single/multi field search condition (e.g. simple or advance)
  32. "showhidecolumns" => true
  33. )
  34. );
  35.  
  36. // this db table will be used for add,edit,delete
  37. $g->table = "clients";
  38.  
  39. $col = array();
  40. $col["title"] = "Id";
  41. $col["name"] = "client_id";
  42. $col["width"] = "20";
  43. $col["editable"] = false;
  44. $col["hidden"] = true;
  45. $cols[] = $col;
  46.  
  47. $col = array();
  48. $col["title"] = "Name";
  49. $col["name"] = "name";
  50. $col["formatter"] = "function(cellvalue, options, rowObject){ return '<DIV title=\"'+rowObject.company+'\">'+cellvalue+'</DIV>'; }";
  51. $col["unformat"] = "function(cellvalue, options, rowObject){ return $.jgrid.stripHtml(cellvalue); }";
  52. $col["editable"] = true;
  53. $col["width"] = "80";
  54. $col["editoptions"] = array("size"=>20);
  55. $cols[] = $col;
  56.  
  57. $col = array();
  58. $col["title"] = "Gender";
  59. $col["name"] = "gender";
  60. $col["width"] = "30";
  61. $col["editable"] = true;
  62. $col["editoptions"]["onfocus"] = "$(this).parent().css('backgroundColor','green')";
  63. $col["editoptions"]["onblur"] = "$(this).parent().css('backgroundColor','inherit')";
  64. $cols[] = $col;
  65.  
  66. $col = array();
  67. $col["title"] = "Company";
  68. $col["name"] = "company";
  69. $col["editable"] = true;
  70. $col["edittype"] = "textarea";
  71. $col["editoptions"] = array("rows"=>2, "cols"=>20);
  72. $cols[] = $col;
  73.  
  74. $col = array();
  75. $col["title"] = "Code";
  76. $col["name"] = "client_id";
  77. $col["width"] = "40";
  78. $col["editable"] = true;
  79. $cols[] = $col;
  80.  
  81. $g->set_columns($cols);
  82.  
  83. // group columns header
  84. $g->set_group_header( array(
  85. "useColSpanStyle"=>true,
  86. "groupHeaders"=>array(
  87. array(
  88. "startColumnName"=>'name', // group starts from this column
  89. "numberOfColumns"=>2, // group span to next 2 columns
  90. "titleText"=>'Personal Information' // caption of group header
  91. ),
  92. array(
  93. "startColumnName"=>'company', // group starts from this column
  94. "numberOfColumns"=>2, // group span to next 2 columns
  95. "titleText"=>'Company Details' // caption of group header
  96. )
  97. )
  98. )
  99. );
  100.  
  101. // generate grid output, with unique grid name as 'list1'
  102. $out = $g->render("list1");
  103. ?>
  104. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  105. <html>
  106. <head>
  107. <link rel="stylesheet" type="text/css" media="screen" href="../../lib/js/themes/redmond/jquery-ui.custom.css"></link>
  108. <link rel="stylesheet" type="text/css" media="screen" href="../../lib/js/jqgrid/css/ui.jqgrid.css"></link>
  109. <script src="../../lib/js/jquery.min.js" type="text/javascript"></script>
  110. <script src="../../lib/js/jqgrid/js/i18n/grid.locale-en.js" type="text/javascript"></script>
  111. <script src="../../lib/js/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>
  112. <script src="../../lib/js/themes/jquery-ui.custom.min.js" type="text/javascript"></script>
  113. </head>
  114. <body>
  115. <div style="margin:10px">
  116. <?php echo $out?>
  117. </div>
  118. </body>
  119. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement