<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
	<title>jQuery Grid Plugin - jqGrid - Topic: search help needed</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/search-help-needed</link>
	<description><![CDATA[Grid plugin]]></description>
	<generator>Simple:Press Version 5.7.5.3</generator>
	<atom:link href="http://www.trirand.com/blog/?page_id=393/help/search-help-needed/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>tim on search help needed</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/search-help-needed#p17736</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/search-help-needed#p17736</guid>
        	        	<description><![CDATA[<p>np <img class="spSmiley" style="margin:0" title="Laugh" src="/blog/wp-content/forum-smileys/sf-laugh.gif" alt="Laugh" /></p>
]]></description>
        	        	<pubDate>Fri, 04 Jun 2010 17:08:20 +0300</pubDate>
        </item>
        <item>
        	<title>ploppy on search help needed</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/search-help-needed#p17735</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/search-help-needed#p17735</guid>
        	        	<description><![CDATA[<p>thanks ever so much tim. much appreciate your time and effort.</p>
]]></description>
        	        	<pubDate>Fri, 04 Jun 2010 17:06:55 +0300</pubDate>
        </item>
        <item>
        	<title>tim on search help needed</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/search-help-needed#p17734</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/search-help-needed#p17734</guid>
        	        	<description><![CDATA[<p>So look at your SQL statements:</p>
<p>$result = mysql_query("SELECT COUNT(*) AS count FROM jqgrid");</p>
<p>$SQL = "SELECT * FROM jqgrid ORDER BY $sidx $sord LIMIT $start ,  $limit";</p>
<p>and compare that to the jqGrid example:</p>
<p>$result = mysql_query("SELECT COUNT(*) AS count FROM invheader a,  clients b WHERE a.client_id=b.client_id");</p>
<p>Yours has no WHERE clause.</p>
<p>You can see the arguments you need to check for:</p>
<p>$row[id],$row[title],$row[director],$row[year],$row[bond],$row[budget]</p>
<p>and you know how to check for them&#8230;</p>
<p>$id= $_GET["id"];</p>
<p>I&#39;m not a php guy so I am not going to start debugging/suggesting your code, but you need to handle the arguments passed into your php script and incorporate them into your SQL statement.</p>
<p>tim</p>
]]></description>
        	        	<pubDate>Fri, 04 Jun 2010 16:55:20 +0300</pubDate>
        </item>
        <item>
        	<title>ploppy on search help needed</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/search-help-needed#p17731</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/search-help-needed#p17731</guid>
        	        	<description><![CDATA[<p>tim</p>
<p>so i understand you correctly, are you saying code in the new.php file is enough to perform and display the results from the click of the find button? i have included the php file i am using to display data. many thanks for your help.</p>
</p>
<p><input type='button' class='sfcodeselect' name='sfselectit6740' value='Select Code' data-codeid='sfcode6740' /></p>
<div class='sfcode' id='sfcode6740'>&#60;?php</p>
<p>// Include the information needed for the connection to<br />// MySQL data base server. <br />include(&#34;dbconfig.php&#34;);<br />//since we want to use a JSON data we should include<br />//encoder and decoder for JSON notation<br />//If you use a php &#62;= 5 this file is not needed<br />include(&#34;JSON.php&#34;);</p>
<p>// create a JSON service<br />$json = new Services_JSON();</p>
<p>// to the url parameter are added 4 parameter<br />// we shuld get these parameter to construct the needed query<br />// for the pager<br />$examp = $_GET[&#34;q&#34;];</p>
<p>// get the requested page<br />$page = $_GET[&#39;page&#39;];<br />// POST how many rows we want to have into the grid<br />// rowNum parameter in the grid<br />$limit = $_GET[&#39;rows&#39;];<br />// POST index row - i.e. user click to sort<br />// at first time sortname parameter - after that the index from colModel<br />$sidx = $_GET[&#39;sidx&#39;];<br />// sorting order - at first time sortorder<br />$sord = $_GET[&#39;sord&#39;]; </p>
<p>// if we not pass at first time index use the first column for the index<br />if(!$sidx) $sidx =1;<br />// connect to the MySQL database server<br />$db = mysql_connect($dbhost, $dbuser, $dbpassword)<br />or die(&#34;Connection Error: &#34; . mysql_error());</p>
<p>// select the database<br />mysql_select_db($database) or die(&#34;Error conecting to db.&#34;);</p>
<p>// calculate the number of rows for the query. We need this to paging the result<br />$result = mysql_query(&#34;SELECT COUNT(*) AS count FROM jqgrid&#34;);<br />$row = mysql_fetch_array($result,MYSQL_ASSOC);<br />$count = $row[&#39;count&#39;];</p>
<p>// calculation of total pages for the query<br />if( $count &#62;0 ) {<br />&#160;&#160; &#160;$total_pages = ceil($count/$limit);<br />} else {<br />&#160;&#160; &#160;$total_pages = 0;<br />}</p>
<p>// if for some reasons the GETed page is greater than the total<br />// set the GETed page to total page<br />if ($page &#62; $total_pages) $page=$total_pages;</p>
<p>// calculate the starting position of the rows<br />$start = $limit*$page - $limit; // do not put $limit*($page - 1)<br />// if for some reasons start position is negative set it to 0<br />// typical case is that the user type 0 for the requested page<br />if($start &#60;0) $start = 0;</p>
<p>// the actual query for the grid data<br />$SQL = &#34;SELECT * FROM jqgrid ORDER BY $sidx $sord LIMIT $start , $limit&#34;;<br />$result = mysql_query( $SQL ) or die(&#34;Couldn t execute query.&#34;.mysql_error());</p>
<p>// constructing a JSON<br />$responce-&#62;page = $page;<br />$responce-&#62;total = $total_pages;<br />$responce-&#62;records = $count;<br />$i=0;<br />while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {<br />&#160;&#160;&#160; $responce-&#62;rows[$i][&#39;id&#39;]=$row[id];<br />&#160;&#160;&#160; $responce-&#62;rows[$i][&#39;cell&#39;]=array($row[id],$row[title],$row[director],$row[year],$row[bond],$row[budget]);<br />&#160;&#160;&#160; $i++;<br />}<br />// return the formated data<br />echo $json-&#62;encode($responce);<br />&#160;&#160; &#160;&#160;&#160; &#160;<br />?&#62;</p>
</div>
<p>if that is the case, i should be seeing results? where are the fields being passed searched? ie,</p>
<table class="netInfoParamsText netInfoText  netInfoParamsTable " border="0" cellspacing="0" cellpadding="0">
<tbody class=" ">
<tr class=" ">
<td class="netInfoParamName ">_search</td>
<td class="netInfoParamValue ">
<p><input type='button' class='sfcodeselect' name='sfselectit521' value='Select Code' data-codeid='sfcode521' /></p>
<div class='sfcode' id='sfcode521'>true</div>
</td>
</tr>
<tr class=" ">
<td class="netInfoParamName ">nd</td>
<td class="netInfoParamValue ">
<p><input type='button' class='sfcodeselect' name='sfselectit2050' value='Select Code' data-codeid='sfcode2050' /></p>
<div class='sfcode' id='sfcode2050'>1275658385590</div>
</td>
</tr>
<tr class=" ">
<td class="netInfoParamName ">page</td>
<td class="netInfoParamValue ">
<p><input type='button' class='sfcodeselect' name='sfselectit4022' value='Select Code' data-codeid='sfcode4022' /></p>
<div class='sfcode' id='sfcode4022'>1</div>
</td>
</tr>
<tr class=" ">
<td class="netInfoParamName ">rows</td>
<td class="netInfoParamValue ">
<p><input type='button' class='sfcodeselect' name='sfselectit255' value='Select Code' data-codeid='sfcode255' /></p>
<div class='sfcode' id='sfcode255'>10</div>
</td>
</tr>
<tr class=" ">
<td class="netInfoParamName ">searchField</td>
<td class="netInfoParamValue ">
<p><input type='button' class='sfcodeselect' name='sfselectit3899' value='Select Code' data-codeid='sfcode3899' /></p>
<div class='sfcode' id='sfcode3899'>id</div>
</td>
</tr>
<tr class=" ">
<td class="netInfoParamName ">searchOper</td>
<td class="netInfoParamValue ">
<p><input type='button' class='sfcodeselect' name='sfselectit8294' value='Select Code' data-codeid='sfcode8294' /></p>
<div class='sfcode' id='sfcode8294'>eq</div>
</td>
</tr>
<tr class=" ">
<td class="netInfoParamName ">searchString</td>
<td class="netInfoParamValue ">
<p><input type='button' class='sfcodeselect' name='sfselectit6124' value='Select Code' data-codeid='sfcode6124' /></p>
<div class='sfcode' id='sfcode6124'>5</div>
</td>
</tr>
<tr class=" ">
<td class="netInfoParamName ">sidx</td>
<td class="netInfoParamValue ">
<p><input type='button' class='sfcodeselect' name='sfselectit3866' value='Select Code' data-codeid='sfcode3866' /></p>
<div class='sfcode' id='sfcode3866'>id</div>
</td>
</tr>
<tr class=" ">
<td class="netInfoParamName ">sord</td>
<td class="netInfoParamValue ">
<p><input type='button' class='sfcodeselect' name='sfselectit5584' value='Select Code' data-codeid='sfcode5584' /></p>
<div class='sfcode' id='sfcode5584'>desc</div>
</td>
</tr>
</tbody>
</table>
<p>many thanks</p></p>
]]></description>
        	        	<pubDate>Fri, 04 Jun 2010 16:34:00 +0300</pubDate>
        </item>
        <item>
        	<title>tim on search help needed</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/search-help-needed#p17730</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/search-help-needed#p17730</guid>
        	        	<description><![CDATA[<p>np.</p>
<p>&#62; does the search need to be built into one these files?</p>
<p>The jqGrid plugin automatically applies the search parameters to your &#39;new.php&#39;,&#160; so you don&#39;t need to specifiy a separate url for searching.</p>
<p>&#62; in new.php as above, does that become new.php?q=1</p>
<p>some demo files have q=1 as part of the base url. So it&#39;s included in every request for data. Tony uses q=1 just to specify which base query he wants to run for a given grid example.</p>
<p>For you, new.php becomes new.php?searchField=id&#38;searchOper=eq&#38;searchString=27</p>
<p>so new.php will include your search.</p>
<p>&#62; the way i see it, there is no other way to pass the values to say  search.php as per the demo files</p>
<p>I&#39;m not sure which example shows &#39;search.php&#39;, I see&#160; &#39;server.php?q=1&#39; , but either way the url name is just a name, and jqGrid will use url:&#39;xxxx.php&#39; the same way no matter what the name is. For ease in understanding I always use &#39;data&#39; in the url name since it better represents what it&#39;s purpose is.</p>
<p>ie. change &#39;new.php&#39; to &#39;data.php&#39; just to make life easier <img class="spSmiley" style="margin:0" title="Cool" src="/blog/wp-content/forum-smileys/sf-cool.gif" alt="Cool" /></p>
<p>tim</p></p>
]]></description>
        	        	<pubDate>Fri, 04 Jun 2010 16:09:43 +0300</pubDate>
        </item>
        <item>
        	<title>ploppy on search help needed</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/search-help-needed#p17729</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/search-help-needed#p17729</guid>
        	        	<description><![CDATA[<p>tim</p>
<p>thanks very much for a detailed explanation. i totally get everything you have said and i know that the passed vars need to be processed by php &#38; mysql. but what i cannot see is where to specify the php page to do this. for example, i have new.php in my sample code that displays the listing. i then have edit.php which handles the add,del etc of records. does the search need to be built into one these files? for example, in new.php as above, does that become new.php?q=1 because i noticed from your sample files that $examp var is expecting this in a $_REQUEST field? if that is the case, do i just build the search criteria into new.php? because the way i see it, there is no other way to pass the values to say search.php as per the demo files? am i getting closer?</p>
<p>many thanks for your time and help tim.</p>
]]></description>
        	        	<pubDate>Fri, 04 Jun 2010 12:48:12 +0300</pubDate>
        </item>
        <item>
        	<title>tim on search help needed</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/search-help-needed#p17724</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/search-help-needed#p17724</guid>
        	        	<description><![CDATA[<p>I&#39;ll do my best, but I don&#39;t think I fully understand you.</p>
<p>&#62; What i am failing to see is if both the display and the search is handled by in my case new.php then how are these filters reacting with the db?</p>
<p>The first post made for your grid to request data is on load and has the following argument:</p>
<p><strong>_search &#160;false</strong></p>
<p>So you can use PHP or whatever to return your base set of data.</p>
<p>When you fill-out the search box and request filtered data, the new post args are different where&#160;</p>
<p><strong>_search&#160;&#160; &#160;true</strong><br />nd&#160;&#160; &#160;1275596107133<br />page&#160;&#160; &#160;1<br />rows&#160;&#160; &#160;10<br />searchField&#160;&#160; &#160;id<br />searchOper&#160;&#160; &#160;eq<br />searchString&#160;&#160; &#160;27<br />sidx&#160;&#160; &#160;id<br />sord&#160;&#160; &#160;desc</p>
<p>Knowing search is now true you need to use server side code (like PHP) to grab these arguments and use them to run a new SQL query that obtains the filtered data.</p>
<p>I&#39;m no PHP guy, but the demo PHP example files typically store the results of the SQL query in a variable like $results, which is in turn echoed back as a response to the post, which then loads the new (and different data) into the grid.</p>
<p>&#62; do i need to communicate with these files or are you saying that all display and search results should be as per my script above and search results should show?</p>
<p>Yes. Your new.php script needs to handle the arguments passed from the client and return filtered data should _search = true.&#160;</p>
</p>
<p>One additional thing I notice is that you have mtype: &#39;POST&#39;.&#160;I generally leave that out so the default is GET as it&#39;s intended to return a response.</p>
</p>
<p>[Edit] All this being said, if your intent is to send the data to the client once, then let them search within the already loaded data, then use &#160;the new local data settings&#8230; I believe searching on large client side data is a new feature in 3.7 so you would need to check the docs for details.</p>
</p>
<p>tim</p></p>
]]></description>
        	        	<pubDate>Fri, 04 Jun 2010 03:32:46 +0300</pubDate>
        </item>
        <item>
        	<title>ploppy on search help needed</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/search-help-needed#p17721</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/search-help-needed#p17721</guid>
        	        	<description><![CDATA[<p>tim</p>
<p>these are filters that are being posted as pre firebug console.</p>
<p>_search&#160;&#160; &#160;true<br />nd&#160;&#160; &#160;1275596107133<br />page&#160;&#160; &#160;1<br />rows&#160;&#160; &#160;10<br />searchField&#160;&#160; &#160;id<br />searchOper&#160;&#160; &#160;eq<br />searchString&#160;&#160; &#160;27<br />sidx&#160;&#160; &#160;id<br />sord&#160;&#160; &#160;desc</p>
</p>
<p>ordinarily, i will pass these filters to a php page and process them based on some kind of isset function based on _search being set(true). what i am failing to see is if both the display and the search is handled by in my case new.php then how are these filters reacting with the db? in my case all i see after pressing the find icon is loading and my grid stays the same. for example, in the demo files there are 2 files, search.php and server.php which on viewing set the vars based on what is passed, then creates some sort of where clause $wh? and reacts with the db. do i need to communicate with these files or are you saying that all display and search results should be as per my script above and search results should show?if this is the case, why is my script not showing the search results based on what i have posted?</p>
</p>
<p>many thanks</p>
]]></description>
        	        	<pubDate>Thu, 03 Jun 2010 23:25:48 +0300</pubDate>
        </item>
        <item>
        	<title>tim on search help needed</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/search-help-needed#p17720</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/search-help-needed#p17720</guid>
        	        	<description><![CDATA[<p>Your original url:&#39;new.php&#39; handles both the&#160; initial load and subsequent loads (includes the search parameters).</p>
<p>Use Firebug or some tool to see the &#39;filters&#39; posted.</p>
<p>tim</p>
]]></description>
        	        	<pubDate>Thu, 03 Jun 2010 22:42:33 +0300</pubDate>
        </item>
        <item>
        	<title>ploppy on search help needed</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/search-help-needed#p17715</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/search-help-needed#p17715</guid>
        	        	<description><![CDATA[<p>any further help with this please. thanks</p>
]]></description>
        	        	<pubDate>Thu, 03 Jun 2010 17:24:46 +0300</pubDate>
        </item>
        <item>
        	<title>ploppy on search help needed</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/search-help-needed#p17672</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/search-help-needed#p17672</guid>
        	        	<description><![CDATA[<p>hello</p>
<p>after many days of trying i am still unable to get the search function to work. i can add,del,edit records, but what i cannot do is search for a record. the search popup appears and whatever i type nothing returns in grid. i have tried using search.php and server.php that come with demo files for 3.5.3 but still no luck. what i am not sure of is how to pass to the results page. for example, i have my grid as this:</p>
</p>
<p><input type='button' class='sfcodeselect' name='sfselectit6347' value='Select Code' data-codeid='sfcode6347' /></p>
<div class='sfcode' id='sfcode6347'>
<p>jQuery(document).ready(function(){ <br />&#160; jQuery(&#34;#list&#34;).jqGrid({<br />&#160;&#160;&#160; url:&#39;new.php&#39;,<br />&#160;&#160;&#160; datatype: &#39;json&#39;,<br />&#160;&#160;&#160; mtype: &#39;POST&#39;,<br />&#160;&#160;&#160; colNames:[&#39;Id&#39;,&#39;Title&#39;, &#39;Director&#39;, &#39;Year&#39;,&#39;Bond&#39;,&#39;Budget&#39;],<br />&#160;&#160;&#160; colModel :[ <br />&#160;&#160;&#160;&#160;&#160; {name:&#39;id&#39;, hidden:true, search: true, index:&#39;id&#39;, width:55},<br />&#160;&#160;&#160;&#160;&#160; {name:&#39;title&#39;, index:&#39;title&#39;, editable:true, width:90},<br />&#160;&#160; &#160;&#160; {name:&#39;director&#39;, index:&#39;director&#39;, editable:true, width:90},<br />&#160;&#160;&#160;&#160;&#160; {name:&#39;year&#39;, index:&#39;year&#39;, editable:true, width:80},<br />&#160;&#160;&#160;&#160;&#160; {name:&#39;bond&#39;, index:&#39;bond&#39;, width:80, search:true, editable:true},<br />&#160;&#160;&#160;&#160;&#160; {name:&#39;budget&#39;, index:&#39;budget&#39;, editable:true, width:80, sortable:false}<br />&#160;&#160;&#160;&#160; &#160;<br />&#160;&#160;&#160; ],<br />&#160;&#160;&#160; pager: &#39;#pager&#39;,<br />&#160;&#160;&#160; rowNum:10,<br />&#160;&#160;&#160; rowList:[10,20,30],<br />&#160;&#160; &#160;imgpath: &#39;themes/ui-lightness/images&#39;,<br />&#160;&#160;&#160; sortname: &#39;id&#39;, <br />&#160;&#160; &#160;autowidth: true,<br />&#160;&#160; &#160;height:&#39;100%&#39;,<br />&#160;&#160; &#160;altRows: true,<br />&#160;&#160; &#160;search: true,<br />&#160;&#160;&#160; sortorder: &#39;desc&#39;,<br />&#160;&#160; &#160;editurl: &#39;edit.php?q=1&#39;,<br />&#160;&#160;&#160; viewrecords: true,<br />&#160;&#160;&#160; caption: &#39;My first grid&#39;<br />&#160; }).navGrid(&#39;#pager&#39;,{search: true, add:true, addtext:&#34;Add a record&#34;, edittext:&#34;Edit a record&#34;, deltext:&#34;delete a record&#34;, searchtext:&#34;Find files&#34;, refreshtext:&#34;Refresh records&#34;, alertcap: &#34;You must select a row to edit&#34;}, //options<br />{closeAfterEdit: true, jqModal: true, reloadAfterSubmit:true}, // edit options<br />{closeAfterAdd: true,reloadAfterSubmit:true}, // add options<br />{reloadAfterSubmit:true}, // del options<br />{onInitializeSearch : function() {alert(&#39;just a test&#39;);}} // search options<br />);<br />&#160;});</p>
</div>
<p>as you can see, i have main grid &#39;new.php&#39; and the editurl &#39;edit.php&#39; where do i put url to search.php so i can send the vars to display them? or is there some other way? hope you can help because this is driving me crazy. i have read the wiki and the docs and can see how the search would work, but just cannot figure it out. many thanks</p>
]]></description>
        	        	<pubDate>Wed, 02 Jun 2010 17:36:06 +0300</pubDate>
        </item>
</channel>
</rss>