Searching is enabled by default, when the navigator option is set to true. In order to customize the search options and events you can use two available methods - setNavEvent and setNavOptions.

Since both methods are general methods for customizing the "navigator" (toolbar) functionality of jqGrid, the first parameter of these methods should refer to searching - i.e the parameter should be a string - "search".


$grid->setNavOptions('search',array(...));
$grid->setNavEvent('search','java_script_code_here');

By default, the searching feature is set to search on multiple fields. If you want to allow searching just on one field at a time, you can set the multipleSearch options to false.

Here is an example:

<?php 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); // Tell the db that we use utf-8 $conn->query("SET NAMES utf8"); // Create the jqGrid instance $grid = new jqGridRender($conn); // Write the SQL Query $grid->SelectCommand = 'SELECT OrderID, OrderDate, CustomerID, ShipName, Freight FROM orders'; // Set output format to json $grid->dataType = 'json'; // Let the grid create the model $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" )); // add navigator with the default properties $grid->navigator = true; //but use single search $grid->setNavOptions('search',array("multipleSearch"=>false)); $grid->renderGrid('#grid','#pager',true, null, null, true,true); $conn = null; ?>