<?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: Integrate jqGrid with Autocomplete</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/integrate-jqgrid-with-autocomplete</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/integrate-jqgrid-with-autocomplete/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>davidbemenderfer on Integrate jqGrid with Autocomplete</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/integrate-jqgrid-with-autocomplete#p12198</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/integrate-jqgrid-with-autocomplete#p12198</guid>
        	        	<description><![CDATA[<p>Per Tony&#39;s advice, I&#39;m trying to implement autocomplete into my project.&#160; I&#39;m using the <a href="http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/" target="_blank">jquery.ui.autocomplete.js</a> file version 1.1 (the latest).&#160; This version is supposed to be included in an upcoming version of the jQuery UI package 1.8.&#160; I&#39;m trying to implement using JSON but my php is not very good.&#160; If my below code is close, maybe someone can tell me what I&#39;m doing wrong.&#160; If I&#39;m off base, maybe&#160;someone can verify or provide a sample of the server side JSON results and&#160;a client side example.&#160; When complete, I will post my working example.&#160; The jqGrid documentation says this can be done but does not provide an example.</p>
<p>Thanks in advance,</p>
<p>-David</p>
</p>
<p>My colModel code</p>
<p><input type='button' class='sfcodeselect' name='sfselectit4099' value='Select Code' data-codeid='sfcode4099' /></p>
<div class='sfcode' id='sfcode4099'>{name:&#39;TimeCode_ID&#39;, &#160;&#160;index:&#39;TimeCode_ID&#39;, &#160;&#160;width:100, &#160;editable:true,&#160; editoptions:{ dataInit : function (elem) {$(elem).autocomplete();}}},</div>
<p>My autocomplete function</p>
<p><input type='button' class='sfcodeselect' name='sfselectit2965' value='Select Code' data-codeid='sfcode2965' /></p>
<div class='sfcode' id='sfcode2965'>function auto_complete(id){<br />&#160;&#160;&#160;&#160;&#160;jQuery(&#8221;#&#8221;+id+&#8221;TimeCode_ID&#8221;,&#8221;#list&#8221;).autocomplete({<br />&#160;&#160;&#160;&#160;&#160;&#160;//$(&#8221;#TimeCode_ID&#8221;).autocomplete({<br />&#160;&#160;&#160;&#160;&#160;&#160;cache: {limit: 15},<br />&#160;&#160;&#160;&#160;&#160;&#160;source: function(request, response) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;$.ajax({<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;dataType: &#8220;JSON&#8221;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;data: {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;style: &#8220;full&#8221;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;maxRows: 15,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;name_startsWith: request.term<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;success: function(data) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color: #ff0000;">response($.map(data.geonames, function(item) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;return {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;label: item.name + (item.adminName1 ? &#8220;, &#8221; + item.adminName1 : &#8220;&#8221;) + &#8220;, &#8221; + item.countryName,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;result: item.name<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}))</span><br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;})<br />&#160;&#160;&#160;&#160;&#160;&#160;},<br />&#160;&#160;&#160;&#160;&#160;&#160;minLength: 1,<br />&#160;&#160;&#160;&#160;&#160;&#160;change: function(event, ui) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;log(ui.item ? (&#8221;Selected: &#8221; + ui.item.label) : &#8220;Nothing selected, input was &#8221; + this.value);<br />&#160;&#160;&#160;&#160;&#160;&#160;},<br />&#160;&#160;&#160;&#160;&#160;&#160;open: function() {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;$(this).removeClass(&#8221;ui-corner-all&#8221;).addClass(&#8221;ui-corner-top&#8221;);<br />&#160;&#160;&#160;&#160;&#160;&#160;},<br />&#160;&#160;&#160;&#160;&#160;&#160;close: function() {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;$(this).removeClass(&#8221;ui-corner-top&#8221;).addClass(&#8221;ui-corner-all&#8221;);<br />&#160;&#160;&#160;&#160;&#160;&#160;}<br />&#160;&#160;&#160;&#160;&#160;});<br />&#160;&#160;&#160;&#160;};</div>
<p>My JSON file results</p>
<p><input type='button' class='sfcodeselect' name='sfselectit2241' value='Select Code' data-codeid='sfcode2241' /></p>
<div class='sfcode' id='sfcode2241'>[{labortype_id: "1",LaborType: "Paralegal Time"}, {labortype_id: "2",LaborType: "Mediator Setup Time"}, {labortype_id: "3",LaborType: "Reschedule(s)"}, {labortype_id: "4",LaborType: "Mediator Preparation Time"}, {labortype_id: "5",LaborType: "Mediate Case"}, {labortype_id: "6",LaborType: "Post Mediation Time"}, {labortype_id: "7",LaborType: "Cancellation"}];</div>
<p>Code that generates the JSON file</p>
<p><input type='button' class='sfcodeselect' name='sfselectit3821' value='Select Code' data-codeid='sfcode3821' /></p>
<div class='sfcode' id='sfcode3821'>&#160;dblCounter = 1<br />&#160;response.write &#8220;["<br />&#160;While Not (rs.EOF Or rs.BOF)<br />&#160;&#160;if dblCounter &#62; 1 then response.write ", "<br />&#160;&#160;response.write "{"<br />&#160;&#160;response.write "labortype_id: """ &#38; trim(rs("labortype_id")) &#38; ""","<br />&#160;&#160;response.write "LaborType: """ &#38; trim(rs("LaborType"))&#38; """"<br />&#160;&#160;response.write "}"<br />&#160;&#160;dblCounter = dblCounter + 1<br />&#160;&#160;response.flush<br />&#160;&#160;rs.MoveNext<br />&#160;Wend<br />&#160;response.write "];&#8221;</div>
]]></description>
        	        	<pubDate>Thu, 19 Nov 2009 13:08:39 +0200</pubDate>
        </item>
</channel>
</rss>