Ok so this is what the filters string unescapes to
{"groupOp":"AND","rules":[{"field":"company_id","op":"eq","data":"CarMax"}]}
the rules look correct, I’m not sure what the groupOp does ??
The demo does work. I’ve included the GET request.
http://parrinc2.com/jqgrid/grid.php?oper=grid&_search=true&nd=1458746712544&rows=10&page=1&sidx=OrderID&sord=asc&searchField=OrderID&searchString=10248&searchOper=eq&filters=
Note that the searchOper, searchString, and searchField are properly populated.
What I mean by default search is that I just set search = true in the navOptions
$grid->setNavOptions('navigator', array("excel"=>false,"add"=>false,"edit"=>false,"del"=>false,"view"=>false, "search"=>true));
I was using the Search Dialog demo from here as a reference.
If I take the GET request and fill in the searchField, searchOper, and searchString the search works properly. As you can see from the original post those fields are not populated.
Below is my entire grid. Its pretty simple. I’m just trying to get the default search working. I’ve been reference the Search Dialog demo from here, http://www.guriddo.net/demo/demos/jqgrid/ . I am using PHP version 5.5.22 and jqGrid version 4.8. I am using Google Chrome Version 48.0.2564.116 m. If I manually fill in the search parameters for the GET request then it works as expected.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
<?php session_start (); $_SESSION['path'] = "../../"; $groupswithaccess="OFFICE"; require_once("../../slpw/sitelokpw.php"); require_once ('../php/common_functions.php'); require_once '../../jq-config.php'; // include the jqGrid Class require_once "../../php/PHPSuito/jqGrid.php"; // include the driver class require_once "../../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"); $noRouteSelected = false; $info = setRouteIDAndTabletID (); $routeID = $info['route']; $tabletID = $info['tablet']; if(isset($info['name'])) $nameID = $info['name']; else $nameID = ""; $truckID = -1; $trailerID = ""; $employeeCount = 0; $q = jqGridDB::query($conn, "SELECT truck_id, trailer_id, employee_count FROM route_expense WHERE date_purchased IS NOT NULL and route_id = '$routeID' and name_id = '$nameID'"); while($row = jqGridDB::fetch_num($q)) { $truckID = $row[0]; $trailerID = $row[1]; $employeeCount = $row[2]; } // Create the jqGrid instance $grid = new jqGridRender($conn); // Write the SQL Query $grid->SelectCommand = "SELECT * from maint_ows where route_id = '$routeID' and name_id = '$nameID'"; $grid->setUserDate ('Y-m-d'); // Set the table to where we add the data $grid->table = 'maint_ows'; // We tell that the primary key is not serial, which should be inserted by the user $grid->serialKey = true; // 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('editStopsGrid.php'); // Set some grid options $grid->setGridOptions(array( "rowNum"=>50, "rowList"=>array(50,100,500), "sortname"=>"date_finished", "autowidth"=>true, "height"=>475, )); // The primary key should be entered $grid->setColProperty('maint_task_id', array("label"=>"Task ID", "editoptions"=>array("readonly"=>true))); $grid->setColProperty('maint_id', array("label"=>"Maint. ID")); $grid->setColProperty('company_id', array("label"=>"Company")); $grid->setColProperty('cat_4', array("label"=>"Cat 4")); $grid->setColProperty('site_id', array("label"=>"Site ID")); $grid->setColProperty('maint_type', array("label"=>"Maint. Type")); $grid->setColProperty('route_id', array("label"=>"Route ID")); $grid->setColProperty('tablet_id', array("label"=>"Tablet ID")); $grid->setColProperty('name_id', array("label"=>"Name ID")); $grid->setColProperty('arrival_time', array("label"=>"Arrival Time")); $grid->setColProperty('date_created', array("label"=>"Date Created")); $grid->setColProperty('lat', array("label"=>"Lat.")); $grid->setColProperty('lon', array("label"=>"Lon.")); $grid->setColProperty('odometer_reading', array("label"=>"Odometer Reading")); $grid->setColProperty('water_treated_gal', array("label"=>"Water Treated")); $grid->setColProperty('sludge_removed_gal', array("label"=>"Sludge Removed")); $grid->setColProperty('trenches_cleaned', array("label"=>"Trenches Cleaned")); $grid->setColProperty('trench_length_feet', array("label"=>"Trench Length")); $grid->setColProperty('rodder_used', array("label"=>"Rodder Used")); $grid->setColProperty('clean_comment', array("label"=>"Clean Comment")); $grid->setColProperty('job_comment', array("label"=>"Job Comment")); $grid->setColProperty('end_time', array("label"=>"End Time")); $grid->setColProperty('date_finished', array("label"=>"Date Finished")); $grid->setColProperty('truck_id', array("label"=>"Truck ID")); $grid->setColProperty('trailer_id', array("label"=>"Trailer ID")); $grid->setColProperty('employee_count', array("label"=>"Employee Count")); // Enable navigator $grid->navigator = true; // Enable only adding $grid->setNavOptions('navigator', array("excel"=>false,"add"=>false,"edit"=>false,"del"=>false,"view"=>false, "search"=>true)); $onselrow = <<< ONSELROW function(rowid, selected) { if(rowid && rowid !== lastSelection) { $("#grid").jqGrid('restoreRow', lastSelection); $("#grid").jqGrid('editRow', rowid, true); lastSelection = rowid; } } ONSELROW; $grid->setNavEvent("edit","beforeSubmit",$submit); $grid->setGridEvent('onSelectRow', $onselrow); $grid->renderGrid('#grid','#pager',true, null, null, true,true); $conn = null; ?> |
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top