j'essaye depuis ce matin de réaliser mon premier grid avec jquery....
Tutorial: Creating Your First Grid

http://www.secondpersonplural.ca/jqgriddocs/index.htm

mais ca ne marche pas , le tableaux s'affiche mais pas de données et comme je débute en jquery j'arrive pas à localiser l'erreur, pourtant j'ai fais du copie/coller en changeant la params de la connexion mysql , y a t-il une possibilité de vérifier les index envoyés par get avec ce plugin et comment
merci ..

le code :

Code sql : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
CREATE TABLE invheader (                                                     
  invid int(11) NOT NULL auto_increment,                                             
  invdate date NOT NULL,                                                          
  client_id int(11) NOT NULL,                                                     
  amount decimal(10,2) NOT NULL default '0.00',                                   
  tax decimal(10,2) NOT NULL default '0.00',                                      
  total decimal(10,2) NOT NULL default '0.00',                                    
  note char(100) default NULL,                                 
  PRIMARY KEY  (id) 
  );

//--------
The html file looks like this:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<html> <head> <title>jqGrid Demo</title> 
<link rel="stylesheet" type="text/css" media="screen" href="themes/basic/grid.css" />
 <link rel="stylesheet" type="text/css" media="screen" href="themes/jqModal.css" />
  <script src="jquery.js" type="text/javascript"></script>
   <script src="jquery.jqGrid.js" type="text/javascript"></script> 
   <script src="js/jqModal.js" type="text/javascript"></script> 
   <script src="js/jqDnR.js" type="text/javascript"></script>
    <script type="text/javascript"> 
	jQuery(document).ready(function()
	{ jQuery("#list").jqGrid({ url:'example.php',
	 datatype: 'xml',
	  mtype: 'GET',
	  colNames:
	  ['Inv No','Date', 'Amount','Tax','Total','Notes'],
	   colModel :[ {name:'invid', index:'invid', width:55},
	    {name:'invdate', index:'invdate', width:90},
		 {name:'amount', index:'amount', width:80, align:'right'},
		  {name:'tax', index:'tax', width:80, align:'right'},
		   {name:'total', index:'total', width:80, align:'right'},
		    {name:'note', index:'note', width:150, sortable:false} ],
			 pager: jQuery('#pager'), rowNum:10, rowList:[10,20,30], 
			 sortname: 'id', sortorder: "desc", viewrecords: true,
			  imgpath: 'themes/basic/images', caption: 'My first grid'  }); });
			   </script> 
			   </head>
			    <body> 
				<table id="list" class="scroll"></table> 
				<div id="pager" class="scroll" style="text-align:center;"></div>
				 </body>
				  </html>
//-------
example.php

//-----------
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php 
//include the information needed for the connection to MySQL data base server. 
// we store here username, database and password 
include("dbconfig.php");
 
// to the url parameter are added 4 parameters as described in colModel
// we should get these parameters to construct the needed query
// Since we specify in the options of the grid that we will use a GET method 
// we should use the appropriate command to obtain the parameters. 
// In our case this is $_GET. If we specify that we want to use post 
// we should use $_POST. Maybe the better way is to use $_REQUEST, which
// contain both the GET and POST variables. For more information refer to php documentation.
// Get the requested page. By default grid sets this to 1. 
$page = $_GET['page']; 
 
// get how many rows we want to have into the grid - rowNum parameter in the grid 
$limit = $_GET['rows']; 
 
// get index row - i.e. user click to sort. At first time sortname parameter -
// after that the index from colModel 
$sidx = $_GET['sidx']; 
 
// sorting order - at first time sortorder 
$sord = $_GET['sord']; 
 
// if we not pass at first time index use the first column for the index or what you want
if(!$sidx) $sidx =1; 
 
// connect to the MySQL database server 
$db = mysql_connect(MYHOST, MYUSER, MYPASS) or die("Connection Error: " . mysql_error()); 
 
                        
// select the database 
mysql_select_db(MYDB) or die("Error connecting to db."); 
// calculate the number of rows for the query. We need this for paging the result 
$result = mysql_query("SELECT COUNT(*) AS count FROM invheader"); 
$row = mysql_fetch_array($result,MYSQL_ASSOC); 
$count = $row['count']; 
 
// calculate the total pages for the query 
if( $count > 0 ) { 
              $total_pages = ceil($count/$limit); 
} else { 
              $total_pages = 0; 
} 
 
// if for some reasons the requested page is greater than the total 
// set the requested page to total page 
if ($page > $total_pages) $page=$total_pages;
 
// calculate the starting position of the rows 
$start = $limit*$page - $limit;
 
// if for some reasons start position is negative set it to 0 
// typical case is that the user type 0 for the requested page 
if($start <0) $start = 0; 
 
// the actual query for the grid data 
 
$SQL = "SELECT invid, invdate, amount, tax,total, note FROM invheader ORDER BY ".$sidx." ". $sord." LIMIT ".$start." , ".$limit;
$result = mysql_query( $SQL ) or die("Couldn't execute query.".mysql_error()); 
echo $SQL;
// we should set the appropriate header information
if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) {
              header("Content-type: application/xhtml+xml;charset=utf-8"); 
} else {
          header("Content-type: text/xml;charset=utf-8");
}
echo "<?xml version='1.0' encoding='utf-8'?>";
echo "<rows>";
echo "<page>".$page."</page>";
echo "<total>".$total_pages."</total>";
echo "<records>".$count."</records>";
 
// be sure to put text data in CDATA
while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
echo "<row id='". $row[invid]."'>";            
            echo "<cell>". $row[invid]."</cell>";
            echo "<cell>". $row[invdate]."</cell>";
            echo "<cell>". $row[amount]."</cell>";
            echo "<cell>". $row[tax]."</cell>";
            echo "<cell>". $row[total]."</cell>";
            echo "<cell><![CDATA[". $row[note]."]]></cell>";
echo "</row>";
}
echo "</rows>"; 
?>