In this example we demonstarte two new options in jqGrid autowidth and rownumbers.
When autowidth is set to true the grid fits to the width of the parent container.
This option does not resize the grid when the width of the parent container changes.
In order to do that a method setGridWidth should be used again with binding a event to the container
The optin rownumbers add additional column which count the rows
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());
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");
}
$et = ">";
echo "";
echo "".$page."";
echo "".$total_pages."";
echo "".$count."";
// be sure to put text data in CDATA
while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
echo "";
echo "". $row[id]." | ";
echo "". $row[invdate]." | ";
echo " | ";
echo "". $row[amount]." | ";
echo "". $row[tax]." | ";
echo "". $row[total]." | ";
echo " | ";
echo "
";
}
echo "";
?>