Home › Forums › Guriddo Suito PHP › Problem with Search
Tagged: search
I am having some issues with the search functionality. Below is what the GET request looks like. As you can see, none of the search parameters are set and there are a lot of escape characters included. Any ideas?
http://parrinc2.com/p/p_admin/allReportGrid.php?oper=grid&_search=true&nd=1458588658643&rows=50&page=1&sidx=company_id&sord=asc&from=2016-03-01&to=2016-03-21&filters=%7B%22groupOp%22%3A%22AND%22%2C%22rules%22%3A%5B%7B%22field%22%3A%22company_id%22%2C%22op%22%3A%22eq%22%2C%22data%22%3A%22CarMax%22%7D%5D%7D&searchField=&searchString=&searchOper=
Hello,
Please in order to get correct support, please specify more details and code.
Escape characters does nothing to do with searching. You see them this way, but actually in php server side we get the the correct values.
What is your problem? What you set? What you do and how yo do this?
What you expect when you perform search?
A code demonstrating the problem is highly recommended.
Also which PHP version is used, Which browser, which browser version, which jqGrid version is used and etc.
I think you have a idea what you should do when you post a problem.
Kind Regards,
Will
Guriddo Support Team
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; ?> |
Hello,
Thank you for the information and code provided.
What you mean with default search?
I do not see any code for default search.
We have a demo called search upon loading – did you refer to this demo or something else.
What you mean with : If I manually fill in the search parameters for the GET request then it works as expected.
Kind Regards
Will
Guriddo Support Team
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.
Hello,
I think that the filters parameters should be get.
So lets go from the beginning.
Try to install our demo on your server.
Actually you will need just to set the config file.
My question is : Is the searching in demo working?
Kind Regards,
Will
Guriddo Support Team
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.
From your initial post the searchField, SearchOper and etc are empty, but filters parameter is used.
With simple words the code check first for filters parameter and then searchOper and etc values.
Check to see if your filters string is correctly build.
Kind Regards,
Will
Guriddo Support Team
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 above means
|
1 2 3 4 |
... SELECT .... FROM .... WHERE company_id = 'CarMax'; ... |
Please, prepare a demo dump tables in the query and send your script code too. I’m sure that this way we will resolve the problem
Regards
Guriddo Support Team
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top