jqgrid aouto在工具栏中搜索

时间:2017-03-24 21:00:34

标签: php jqgrid

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

<?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);

?>

1 个答案:

答案 0 :(得分:0)

尝试将过滤条的searchOnEnter选项设置为false。像

这样的东西
$grid->setFilterOptions(array("stringResult"=>true,"searchOn‌​Enter"=>false));
相关问题