Advertisement
Guest User

Untitled

a guest
May 7th, 2012
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.72 KB | None | 0 0
  1. I'm following the tutorial but no datepicker appears.   Here are my two files.
  2.  
  3. //////////index.php//////////
  4.  
  5. </html></body>
  6. <div id="pager"></div><table id="grid"></table>
  7.  
  8. <body>
  9. </head>  </script>   });     <?php include "grid1.php";?>    $(document).ready(function() {  $.jgrid.useJSON = true; $.jgrid.no_legacy_api = true;  <script>     <script src="jqueryui/development-bundle/ui/jquery.ui.datepicker.js" type="text/javascript"></script>   <script src="jqueryui/development-bundle/ui/jquery.ui.core.js" type="text/javascript"></script>     <script src="jqueryui/js/jquery-ui-1.8.20.custom.min.js" type="text/javascript"></script>   <script src="jqGridPHP_Sources_4_3_2_0/js/src-grid/jquery.jqGrid.js" type="text/javascript"></script>  <script src="jqGridPHP_Sources_4_3_2_0/js/i18n/grid.locale-en.js" type="text/javascript"></script>  <script src="js/jquery-1.7.2.js" type="text/javascript"></script>    </style>
  10. <style type="text/css">
  11. <link rel="stylesheet" type="text/css" media="screen" href="jqGridPHP_Sources_4_3_2_0/themes/ui.multiselect.css" /> <link rel="stylesheet" type="text/css" href="jqGridPHP_Sources_4_3_2_0/themes/ui.jqgrid.css" /> <link rel="stylesheet" type="text/css" href="jqueryui/development-bundle/themes/redmond/jquery-ui-1.8.20.custom.css" />  <meta charset="UTF-8"> <title>jqGrid</title>
  12. <head><html>  <!doctype html>
  13.  
  14. /////////////grid1.php//////////////
  15.  
  16. <?php
  17.  
  18. // include database configuration credentials
  19. require_once 'jqGridPHP_Sources_4_3_2_0/jq-config.php';
  20. // include the jqGrid Class
  21. require_once "jqGridPHP_Sources_4_3_2_0/php/jqGrid.php";
  22. // include the PDO driver class
  23. require_once "jqGridPHP_Sources_4_3_2_0/php/jqGridPdo.php";
  24. // Connection to the server
  25. $conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
  26. // instruct the database that we use utf-8 encoding
  27. $conn->query("SET NAMES utf8");
  28. // Create the jqGrid instance
  29. $grid = new jqGridRender($conn);
  30. // Write the SQL Query
  31. $grid->SelectCommand = 'SELECT OrderID, CustomerID, EmployeeID, OrderDate  FROM orders';
  32.  
  33. // set the ouput format to json
  34. $grid->dataType = 'json';
  35.  
  36. // Definition of the labels
  37. $mylabels = array("OrderID"=>"Order ID", "CustomerID"=>"Customer ID", "EmployeeID"=>"Employee ID", "OrderDate"=>"OrderDate");
  38. // Let the grid create the model with the desired labels
  39. $grid->setColModel(null, null, $mylabels);
  40. // Change some property of the field(s)
  41. $grid->setColProperty("OrderDate", array("width"=>100));
  42.  
  43.  
  44. // Set the url from where we obtain the data
  45. // make sure this path is the same as your include in your main page
  46. $grid->setUrl('grid1.php');
  47.  
  48. // Set grid caption using the option caption
  49. $grid->setGridOptions(array(
  50.     "caption"=>"Northwinds Orders",
  51.     "rowNum"=>1000,
  52.     "sortname"=>"EmployeeID",
  53.     "rowList"=>array(10,20,1000)
  54.     ));
  55.  
  56. $grid->setGridOptions(array("width"=>1000));
  57. $grid->setGridOptions(array("height"=>350));
  58.  
  59.  
  60.  
  61.  
  62. // javascriptCode for the datepicker
  63. $mydatepicker = <<<DATEPICK
  64. function(el)
  65. {
  66.    setTimeout(function(){
  67.       jQuery(el).datepicker({dateFormat:'dd/mm/yy'});
  68.    },200);
  69. }
  70. DATEPICK;
  71.  
  72. // Set the column property
  73. $grid->setColProperty('OrderDate', array(
  74.    "formatter"=>'date',
  75.    "editoptions"=>array("dataInit"=>"js:".$mydatepicker),
  76.    "searchoptions"=>array("dataInit"=>"js:".$mydatepicker)
  77. ));
  78.  
  79. // add navigator with the default properties
  80. $grid->navigator = true;
  81.  
  82.  
  83.  
  84. /*
  85. $onselect = <<<ONSELECTROW
  86. function(rowid, selected)
  87. {
  88.    alert(rowid);
  89. }
  90. ONSELECTROW;
  91.  
  92. $grid->setGridEvent('onSelectRow',$onselect);
  93. */
  94.  
  95.  
  96.  
  97.  
  98. // Run the script
  99. $grid->renderGrid('#grid','#pager',false, null, null, false, false, true);
  100. //renderGrid( $tblelement, $pager , $script , $summary, $params , $createtbl , $createpg , $echo );
  101.  
  102. // clear database connection
  103. $conn = null;
  104.  
  105.  
  106. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement