For this purpose we introduce a new grid parameter - rowTotal. When set, this paramater (again with loadonce parameter set to true) instruct the server to load the total number of rows needed to work on.
Note that rowNum determines the total records displayed in the grid, while rowTotal the total rows on wich we operate.
When this parameter is set we send a aditional parameter to server named totalrows.
Setting rowTotal to rowTotal = -1 loads all the data from the query.
Setting rowTotal to any number greater than 0 (zero) (usually this should be greater than rowNum) loads only this number of rows.
Below is example, where we load all the data and then we operate on it locally.
grid.php
<?php // include the database connection settings/configuration require_once 'jq-config.php'; // include the jqGrid Class require_once "php/jqGrid.php"; // include the driver class require_once "php/jqGridPdo.php"; // connection to the server $conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD); // instruct the database that we use utf-8 encoding $conn->query("SET NAMES utf8"); // Create the jqGrid instance $grid = new jqGridRender($conn); // set the SQL select query $grid->SelectCommand = 'SELECT OrderID, OrderDate, CustomerID, ShipName, Freight FROM orders'; // Set output format to json $grid->dataType = 'json'; // Let the grid automatically create the model based on the SQL query $grid->setColModel(); // Set the url from where we obtain the data $grid->setUrl('grid.php'); // Set some grid options $grid->setGridOptions(array( "rowNum"=>10, "rowList"=>array(10,20,30), "sortname"=>"OrderID", //this instruct grid to load data only once and then go to local mode "loadonce"=>true, //this instruct grid to load all the data from the query. //If you want by example to load only 500 records, the set it to 500 "rowTotal" => -1 )); //enable navigator, so that we can search $grid->navigator = true; $grid->setNavOptions('navigator', array("excel"=>false,"add"=>false,"edit"=>false,"del"=>false,"view"=>true, "search"=>true)); $grid->renderGrid('#grid','#pager',true, null, null, true,true); $conn = null; ?>