工具栏中的 jqgrid aouto 搜索



正如标题中所写的那样,我需要更改工具栏中的搜索,而不是单击 Enter 进行搜索以在键入过程中自动搜索。这是我的代码。恳请我需要这个工作,因为我的客户要求这样做

<?php
require_once 'jq-config.php';
// include the jqGrid Class
require_once ABSPATH."php/PHPSuito/jqGrid.php";
// include the driver class
require_once ABSPATH."php/PHPSuito/DBdrivers/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);
// Data from this SQL is 1252 encoded, so we need to tell the grid
// Set the SQL Data source
$table = 'users';
$grid->SelectCommand ='SELECT id, balance, userName, userPass, userEmail, 
status, City, dateOfBirth, registrationDate, tvs, guestMod, phone1, phone2  
FROM '.$table;
// set the ouput format to XML
$grid->dataType = 'json';
// Let the grid create the model
$grid->setPrimaryKeyId("id");
$grid->setColModel();
$grid->table = $table;
// set labels in the header
$grid->setColProperty("id", 
array("width"=>"20","label"=>"ID","editable"=>false, "key"=>true) );
$grid->setColProperty("balance", array("width"=>"20","label"=>"Balance") );
$grid->setColProperty("userName", array("width"=>"40","label"=>"User 
Name"));    
$grid->setColProperty("userPass", array("width"=>"30","label"=>"User 
Password"));
$grid->setColProperty("userEmail", array("width"=>"50","label"=>"User 
Email"));
$grid->setColProperty("status", array("width"=>"20","label"=>"Status"));
$grid->setColProperty("City", array("width"=>"30","label"=>"City"));
$grid->setColProperty("dateOfBirth", array("width"=>"30","label"=>"Date Of 
Birth"));
$grid->setColProperty("registrationDate", 
array("width"=>"50","label"=>"Registration 
Date","formatter"=>"datetime","formatoptions"=>array("srcformat"=>"Y-m-
d","newformat"=>"Y-m-d")));
$grid->setColProperty("tvs", array("width"=>"20","label"=>"Tvs"));
$grid->setColProperty("guestMod", array("width"=>"20","label"=>"Guest 
Mod"));
$grid->setColProperty("phone1", array("width"=>"25","label"=>"phone 1"));
$grid->setColProperty("phone2", array("width"=>"25","label"=>"phone 2"));


// Date options to edit
 $grid->setUserDate("Y-m-d");
 $grid->setUserTime("Y-m-d");
$grid->setDatepicker('registrationDate');
$grid->datearray = array("registrationDate");
// we set the select for ship city
$grid->setSelect("guestMod", "SELECT DISTINCT guestMod, guestMod AS guestMod 
FROM users ORDER BY id", false, false, true, array(""=>"All"));
$grid->setSelect("City", "SELECT DISTINCT City, City AS City FROM users 
ORDER BY id", false, false, true, array(""=>"All"));

// 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"=>"id","hoverrows"=>true , "width"=>"1500","height"=>"500" ));
// Enable toolbar searching
$grid->toolbarfilter = true;

$grid->navigator = true;
$grid->setNavOptions('navigator', 
array("excel"=>false,"add"=>false,"edit"=>true,"del"=>true,"view"=>true, 
"search"=>true));

$buttonoptions = array("#pager",
array("caption"=>"Csv", "title"=>"Export to CSV", "onClickButton"=>"js: 
function(){
    jQuery('#grid').jqGrid('exportToCsv');}"
)
);
$grid->callGridMethod("#grid", "navButtonAdd", $buttonoptions);
$buttonoptions = array("#pager",
array("caption"=>"Excel", "title"=>"Export to Escel", "onClickButton"=>"js: 
function(){
    jQuery('#grid').jqGrid('exportToExcel');}"
)
);
$grid->callGridMethod("#grid", "navButtonAdd", $buttonoptions);
$buttonoptions = array("#pager",
array("caption"=>"Pdf", "title"=>"Export to PDF", "onClickButton"=>"js: 
function(){
    jQuery('#grid').jqGrid('exportToPdf');}"
)
);
$grid->callGridMethod("#grid", "navButtonAdd", $buttonoptions);

 // Close the dialog after editing
$grid->setNavOptions('edit',array(
"closeAfterEdit"=>true,
"height"=>"auto",
"dataheight"=>"auto",
"template"=>$template,
"editCaption"=>"Update Customer",
"bSubmit"=>"Update"
));

 $grid->setFilterOptions(array("stringResult"=>true));
 // Enjoy
 $grid->renderGrid('#grid','#pager',true, null, null, true,true);
?>
尝试将

过滤器栏searchOnEnter选项设置为 false 。类似的东西

$grid->setFilterOptions(array("stringResult"=>true,"searchOn‌​Enter"=>false));

最新更新