JimInWoodstock

MyGridCode

Mar 22nd, 2016
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /**
  3.  * PHP Grid Component
  4.  *
  5.  * @author Abu Ghufran <[email protected]> - http://www.phpgrid.org
  6.  * @version 2.0.0
  7.  * @license: see license.txt included in package
  8.  */
  9.  
  10. include_once("../../config.php");
  11.  
  12. include(PHPGRID_LIBPATH."inc/jqgrid_dist.php");
  13.  
  14. // Database config file to be passed in phpgrid constructor
  15. $db_conf = array(
  16.     "type"      => PHPGRID_DBTYPE,
  17.     "server"    => PHPGRID_DBHOST,
  18.     "user"      => PHPGRID_DBUSER,
  19.     "password"  => PHPGRID_DBPASS,
  20.     "database"  => PHPGRID_DBNAME
  21. );
  22.  
  23.     $g = new jqgrid($db_conf);
  24.     $grid["caption"] = "Sample Grid";
  25.     $g->set_options($grid);
  26.     $g->table = "clients";
  27.     $flds = array();
  28.     $flds[] = 'client_id';
  29.     $flds[] = 'name';
  30.     $flds[] = 'gender';
  31.     $flds[] = 'company';
  32.     $cols = array();
  33.     foreach($flds as $f) {
  34.         $col = array();
  35.         $col["title"] = ucwords(str_replace("_", " ", $f));
  36.         $col["name"] = $f;
  37.         if ($f == 'client_id') {
  38.             $col["hidden"] = true;
  39.             $col["editrules"] = array("edithidden" => false);
  40.         }
  41.         if ($f == 'company')  {
  42.            $col['link'] = "http://www.mysite.com/Docs/{company}";
  43.         }
  44.         $col["editable"] = false;
  45.         $cols[] = $col;
  46.     }
  47.     $g->set_columns($cols, true);
  48.     $out = $g->render("list1");
  49. ?>
  50. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  51. <html>
  52. <head>
  53.     <link rel="stylesheet" type="text/css" media="screen" href="../../lib/js/themes/redmond/jquery-ui.custom.css"></link>
  54.     <link rel="stylesheet" type="text/css" media="screen" href="../../lib/js/jqgrid/css/ui.jqgrid.css"></link>
  55.  
  56.     <script src="../../lib/js/jquery.min.js" type="text/javascript"></script>
  57.     <script src="../../lib/js/jqgrid/js/i18n/grid.locale-en.js" type="text/javascript"></script>
  58.     <script src="../../lib/js/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>
  59.     <script src="../../lib/js/themes/jquery-ui.custom.min.js" type="text/javascript"></script>
  60. </head>
  61. <body>
  62. <div>
  63.     <?php echo $out?>
  64. </div>
  65. </body>
  66. </html>
Advertisement