This sample demonstrates the new rendering engine of jqGrid.
In the versions before 3.5 beta jqGrid renders a big data sets slow. This is changed in 3.5 beta.
By default jqGrid renders a data 3-5 time faster compared with previous releses, but there is a more.
When we use the option griedview set to true it is possibe to speed the reading process from 5-10 times.
This is achieved by reading the data at once. This mode has some limitations - it is not possible to use
treeGrid, subGrid and afterInsertRow (event). Enjoy the speed!
HTML
...
Java Scrpt code
jQuery("#speed").jqGrid({
url:'bigset.php',
datatype: "json",
height: 255,
width: 600,
colNames:['Index','Name', 'Code'],
colModel:[
{name:'item_id',index:'item_id', width:65},
{name:'item',index:'item', width:150},
{name:'item_cd',index:'item_cd', width:100}
],
rowNum:200,
rowList:[100,200,300],
mtype: "POST",
rownumbers: true,
rownumWidth: 40,
gridview: true,
pager: '#speedp',
sortname: 'item_id',
viewrecords: true,
sortorder: "asc",
caption: "Using gridview mode",
gridComplete : function() {
var tm = jQuery("#speed").jqGrid('getGridParam','totaltime');
$("#speed_div").html("Render time: "+ tm+" ms ");
}
});
PHP with MySQL (bigset.php)
0 ) {
$total_pages = ceil($count/$limit);
} else {
$total_pages = 0;
}
if ($page > $total_pages) $page=$total_pages;
if ($limit<0) $limit = 0;
$start = $limit*$page - $limit; // do not put $limit*($page - 1)
if ($start<0) $start = 0;
$SQL = "SELECT item_id, item, item_cd FROM items ".$where." ORDER BY $sidx $sord LIMIT $start , $limit";
$result = mysql_query( $SQL ) or die("Couldnt 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[item_id];
$responce->rows[$i]['cell']=array($row[item_id],$row[item],$row[item_cd]);
$i++;
}
echo $json->encode($responce); // coment if php 5
//echo json_encode($responce);
mysql_close($db);
?>