Advertisement
Guest User

Grid

a guest
Nov 13th, 2014
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.49 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("lib/phpgrid/config.php");
  12.  
  13. // set up DB
  14. mysql_connect(PHPGRID_DBHOST, PHPGRID_DBUSER, PHPGRID_DBPASS);
  15. mysql_select_db(PHPGRID_DBNAME);
  16.  
  17. // include and create object
  18. include(PHPGRID_LIBPATH."inc/jqgrid_dist.php");
  19.  
  20. $g = new jqgrid();
  21.  
  22. // set table for CRUD operations
  23. $g->table = "hours";
  24.  
  25. $grid["caption"] = "Bootstrap UI Testing";
  26. $grid["form"]["position"] = "center";
  27. $grid["autowidth"] = true;
  28. $grid["autoresize"] = true; // responsive effect
  29. $g->set_options($grid);
  30.  
  31. $col = array();
  32.  
  33. $col["title"] = "Date Submitted"; // caption of column
  34. $col["name"] = "dtsubmit"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  35. $col["editable"] = true;
  36. $col["width"] = "30";
  37. $cols[] = $col;
  38.  
  39. $col["title"] = "Date Volunteered"; // caption of column
  40. $col["name"] = "dtvol"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  41. $col["editable"] = true;
  42. $col["required"] = true;
  43. $cols[] = $col;
  44.  
  45. $col = array();
  46. $col["title"] = "Hours"; // caption of column
  47. $col["name"] = "hours"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  48. $col["editable"] = true;
  49. $cols[] = $col;
  50.  
  51. $col = array();
  52. $col["title"] = "Activity"; // caption of column
  53. $col["name"] = "activity"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
  54. $col["editable"] = true;
  55. $col["editoptions"] = array("defaultValue" => "Default Company");
  56. $cols[] = $col;
  57.  
  58. $g->set_columns($cols);
  59.  
  60. $g->set_actions(array(
  61. "add"=>true, // allow/disallow add
  62. "edit"=>true, // allow/disallow edit
  63. "delete"=>true, // allow/disallow delete
  64. "clone"=>true, // allow/disallow delete
  65. "rowactions"=>true, // show/hide row wise edit/del/save option
  66. "search" => "advance", // show single/multi field search condition (e.g. simple or advance)
  67. "showhidecolumns" => false
  68. )
  69. );
  70. // render grid
  71. $out = $g->render("list1");
  72.  
  73. $themes = array("black-tie","blitzer","cupertino","dark-hive","dot-luv","eggplant","excite-bike","flick","hot-sneaks","humanity","le-frog","mint-choc","overcast","pepper-grinder","redmond","smoothness","south-street","start","sunny","swanky-purse","trontastic","ui-darkness","ui-lightness","vader");
  74. $i = rand(0,8);
  75.  
  76. // if set from page
  77. if (is_numeric($_GET["themeid"]))
  78. $i = $_GET["themeid"];
  79. else
  80. $i = 14;
  81. ?>
  82. <!DOCTYPE html>
  83. <html lang="en">
  84. <head>
  85. <meta charset="utf-8">
  86. <title>PHP Grid Control Demos | www.phpgrid.org</title>
  87. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  88. <meta name="description" content="">
  89. <meta name="author" content="">
  90.  
  91. <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
  92. <!--[if lt IE 9]>
  93. <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
  94. <![endif]-->
  95.  
  96. <link rel="stylesheet" type="text/css" media="screen" href="lib/phpgrid/lib/js/themes/humanity/jquery-ui.custom.css">
  97. <link rel="stylesheet" type="text/css" media="screen" href="lib/phpgrid/lib/js/jqgrid/css/ui.jqgrid.css">
  98. <link href="lib/phpgrid/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  99. <link rel="stylesheet" type="text/css" media="screen" href="lib/phpgrid/lib/js/jqgrid/css/ui.bootstrap.jqgrid.css">
  100. <script src="lib/phpgrid/lib/js/jquery.min.js" type="text/javascript"></script>
  101. <script src="lib/phpgrid/lib/js/jqgrid/js/i18n/grid.locale-en.js" type="text/javascript"></script>
  102. <script src="lib/phpgrid/lib/js/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>
  103. <script src="lib/phpgrid/lib/js/themes/jquery-ui.custom.min.js" type="text/javascript"></script>
  104.  
  105. </head>
  106.  
  107. <body>
  108. <div class="row-fluid">
  109. <div class="span12">
  110. <div style="margin:10px">
  111. <form method="get">
  112. Choose Theme: <select name="themeid" onchange="form.submit()">
  113. <?php foreach($themes as $k=>$t) { ?>
  114. <option value=<?php echo $k?> <?php echo ($i==$k)?"selected":""?>><?php echo ucwords($t)?></option>
  115. <?php } ?>
  116. </select> -
  117. You can also have your customized theme (<a href="http://jqueryui.com/themeroller">jqueryui.com/themeroller</a>).
  118. </form>
  119. <?php echo $out?>
  120. </div>
  121. </div><!--/span-->
  122. </div><!--/row-->
  123.  
  124. </body>
  125. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement