This example demostrates all get methods in grid. Try to sort column
or double click some row.


Get url
Get Sort Name
Get Sort Order
Get Selected Row
Get Current Page
Get Number of Rows requested
Get Selected Rows
Get Data Type requested
Get number of records in Grid

HTML ... <table id="list6" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="pager6" class="scroll" style="text-align:right;"></div> <br /> <a href="javascript:void(0)" id="g1" onclick="alert(jQuery('#list6').getGridParam('url'));">Get url</a> <br /> <a href="javascript:void(0)" id="g2" onclick="alert(jQuery('#list6').getGridParam('sortname'));">Get Sort Name</a> <br /> <a href="javascript:void(0)" id="g3" onclick="alert(jQuery('#list6').getGridParam('sortorder'));">Get Sort Order</a> <br /> <a href="javascript:void(0)" id="g4" onclick="alert(jQuery('#list6').getGridParam('selrow'));">Get Selected Row</a> <br /> <a href="javascript:void(0)" id="g5" onclick="alert(jQuery('#list6').getGridParam('page'));">Get Current Page</a> <br /> <a href="javascript:void(0)" id="g6" onclick="alert(jQuery('#list6').getGridParam('rowNum'));">Get Number of Rows requested</a> <br /> <a href="javascript:void(0)" id="g7" onclick="alert('See Multi select rows example');">Get Selected Rows</a> <br /> <a href="javascript:void(0)" id="g8" onclick="alert(jQuery('#list6').getGridParam('datatype'));">Get Data Type requested</a> <br /> <a href="javascript:void(0)" id="g9" onclick="alert(jQuery('#list6').getGridParam('records'));">Get number of records in Grid</a> Java Scrpt code ... jQuery("#list6").jqGrid({ url:'server.php?q=2&nd='+new Date().getTime(), datatype: "json", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name', width:100}, {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} ], rowNum:10, //rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#pager6'), sortname: 'id', viewrecords: true, sortorder: "desc", onSortCol: function(name,index){ alert("Column Name: "+name+" Column Index: "+index);}, ondblClickRow: function(id){ alert("You double click row with id: "+id);}, caption:" Get Methods", height: 200 }); jQuery("#list6").navGrid("#pager6",{edit:false,add:false,del:false}); PHP with MySQL ... $page = $_GET['page']; // get the requested page $limit = $_GET['rows']; // get how many rows we want to have into the grid $sidx = $_GET['sidx']; // get index row - i.e. user click to sort $sord = $_GET['sord']; // get the direction if(!$sidx) $sidx =1; // connect to the database $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error()); mysql_select_db($database) or die("Error conecting to db."); $result = mysql_query("SELECT COUNT(*) AS count FROM invheader a, clients b WHERE a.client_id=b.client_id"); $row = mysql_fetch_array($result,MYSQL_ASSOC); $count = $row['count']; if( $count >0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $start = $limit*$page - $limit; // do not put $limit*($page - 1) $SQL = "SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note FROM invheader a, clients b WHERE a.client_id=b.client_id ORDER BY $sidx $sord LIMIT $start , $limit"; $result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error()); $responce->page = $page; $responce->total = $total_pages; $responce->records = $count; $i=0; while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { $responce->rows[$i]['id']=$row[id]; $responce->rows[$i]['cell']=array($row[id],$row[invdate],$row[name],$row[amount],$row[tax],$row[total],$row[note]); $i++; } echo json_encode($responce); ...