<?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: setting the "editoption" 'value' field for a select box</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/setting-the-editoption-value-field-for-a-select-box</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/setting-the-editoption-value-field-for-a-select-box/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>tony on setting the "editoption" 'value' field for a select box</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/setting-the-editoption-value-field-for-a-select-box#p1168</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/setting-the-editoption-value-field-for-a-select-box#p1168</guid>
        	        	<description><![CDATA[<p>We have here a lot of possible solutions.</p>
<p>1. Setting the values direct via script - here is PHP example:</p>
<p>When you call the page with a grid - call it as php page and not as html</p>
<p>colModel [{....</p>
<p>{name:"mayname"...editable:true,edittype:"select",</p>
<p>editoptions:{&#39;&#60;?=$myeditoptions?&#62;&#39;}...},</p>
<p>...</p>
<p>]</p>
<p>where the variable $myeditoptions holds the values from the db</p>
<p>This is the recommendet solution. If this is not possible</p>
<p>2. We can use the method from previous post. We can cal this after the grid is constructed.It is not too late - why?</p>
<p>$.get(&#8221;myurl&#8221;,data:mydata,function(result,status){</p>
<p>if (status == &#8220;success&#8221;) {</p>
<p>// get the result here, suppose that in myselect are the values</p>
<p>$(&#8221;#mygrid&#8221;).setColProp(&#8221;myname&#8221;,{editoptions:{myselects}});</p>
<p>&#8230;</p>
<p>}</p>
<p>}</p>
<p>3. Another possible solution is to use the userData in jqGrid -</p>
<p>(this is another elegant solution). See userData examples haw to do that.</p>
<p>Then</p>
<p>loadComplete : function() {</p>
<p>// get the userData here and convert it to format supported</p>
<p>// in colModel then the same tehchniquie as from 2</p>
<p>$(&#8221;#mygrid&#8221;).setColProp(&#8221;myname&#8221;,{editoptions:{myselects}});</p>
<p>&#8230;</p>
<p>}</p>
</p>
<p>~Enjoy</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Sun, 20 Jul 2008 04:00:00 +0300</pubDate>
        </item>
        <item>
        	<title>ziv1848 on setting the "editoption" 'value' field for a select box</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/setting-the-editoption-value-field-for-a-select-box#p1162</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/setting-the-editoption-value-field-for-a-select-box#p1162</guid>
        	        	<description><![CDATA[<p>Hi Tony!</p>
<p>This is my first post, so I&#39;d like to take this opportunity to thank you</p>
<p>for the great job you&#39;ve done.</p>
<p>I have the same problem, i.e. I&#39;m trying to dynamically fill the select box</p>
<p>with the server-side data. I did what you&#39;ve proposed:</p>
<p>1) call $.get() before constructing the grid</p>
<p>2)&#160; put its result into a variable</p>
<p>3) set that variable in value:name pair of the select box editoptions</p>
<p>in colModel.</p>
</p>
<p>This didn&#39;t work because of $.get() executing&#160; an AJAX call asynchronously</p>
<p>so that the abovementioned variable is assigned before the AJAX call is</p>
<p>finished and gets &#39;undefined&#39; value accordingly.</p>
<p>The only way I found to make the stuff work is to use $.ajax() with async</p>
<p>set to &#39;false&#39; ( instead of calling $.get() ) :</p>
<p>===========================</p>
<p>jQuery(document).ready(function(){</p>
<p>&#160;&#160;&#160; var <strong>selectValue</strong> = $.ajax({</p>
<p>&#160;&#160;&#160; &#160;&#160;  &#160;&#160;  &#160;&#160;  &#160;&#160;  url: "get_some_params_url",</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <strong>async: false</strong></p>
<p>&#160;&#160;&#160; }).responseText;</p>
<p>.............</p>
<p>&#160;&#160;&#160; colModel : [</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; ..........</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; edittype: "select",</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; editoptions: {value: <strong>selectValue</strong>}</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; },</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; .........</p>
<p>&#160;&#160;&#160; ],</p>
<p>}</p>
<p>========================</p>
</p>
<p>Which&#160; is obviously not performance "friendly". It would be great to get</p>
<p>an option just to put a function making an AJAX call into &#39;editoptions&#39;, so</p>
<p>that the call will be fired off only when you click on a select box to pick the</p>
<p>value.</p>
<p>Thanks a lot.</p>
]]></description>
        	        	<pubDate>Fri, 18 Jul 2008 12:33:25 +0300</pubDate>
        </item>
        <item>
        	<title>tony on setting the "editoption" 'value' field for a select box</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/setting-the-editoption-value-field-for-a-select-box#p880</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/setting-the-editoption-value-field-for-a-select-box#p880</guid>
        	        	<description><![CDATA[<p>Try first without cgi script. If all is ok then something with a call is not correct</p>
<p>Tony</p>
<p>P.S</p>
<p>Not sure if you can use get inside this. I recommend you call get before constructing the grid. Set the result in variable and put this in colModel</p>
]]></description>
        	        	<pubDate>Tue, 24 Jun 2008 09:06:43 +0300</pubDate>
        </item>
        <item>
        	<title>stewbagz on setting the "editoption" 'value' field for a select box</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/setting-the-editoption-value-field-for-a-select-box#p876</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/setting-the-editoption-value-field-for-a-select-box#p876</guid>
        	        	<description><![CDATA[<p>Hi Tony,</p>
<p>Thanks for the response, but it&#39;s not quite what I&#39;m after.</p>
<p>I&#39;ve got a little perl script which returns the text (minus the trailing semi-colon) okay, I just can&#39;t force that data into the editoptions when the grid loads, i guess what I&#39;m really after is how to craft a line along the following lines;</p>
<p>---</p>
<p>{name:&#39;col1&#39;,index:&#39;col1&#39;,editable:true,edittype:"select",editoptions:{value: $.get(&#39;<a href="http://localhost/cgi-bin/selectvalues.cgi&#038;#39" rel="nofollow" target="_blank"><a href="http://localhost/cgi-bin/selec" rel="nofollow">http://localhost/cgi-bin/selec</a>.....i&#038;#39</a>;)}},</p>
<p>---</p>
<p>(the above doesn&#39;t work,btw)</p>
<p>Where the editoptions are pulled from the .cgi script. I can see the script fire, I just can&#39;t get it fill the select box with the values (I&#39;ve even tried getting the script to return a hand-coded list without the trailing semi-colon, and it still doesn&#39;t populate the select box)</p>
</p>
<p>Thanks for your time</p>
<p>Kind regs</p>
<p>Stew</p></p>
]]></description>
        	        	<pubDate>Tue, 24 Jun 2008 04:26:34 +0300</pubDate>
        </item>
        <item>
        	<title>tony on setting the "editoption" 'value' field for a select box</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/setting-the-editoption-value-field-for-a-select-box#p871</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/setting-the-editoption-value-field-for-a-select-box#p871</guid>
        	        	<description><![CDATA[<p>The last item should not have this ; at end - i.e the right is</p>
<p>item1:value1;item2:value2;...itemN:valueN</p>
<p>Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Mon, 23 Jun 2008 12:35:08 +0300</pubDate>
        </item>
        <item>
        	<title>stewbagz on setting the "editoption" 'value' field for a select box</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/setting-the-editoption-value-field-for-a-select-box#p870</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/setting-the-editoption-value-field-for-a-select-box#p870</guid>
        	        	<description><![CDATA[<p>First up, props for a super jQuery plugin - it really is very neat indeed!</p>
<p>I&#39;m using jqgrid from a perl script, and I can&#39;t seem to craft an incantation to populate the a select box from a perl script. If I use a hard-coded values:"&#60;blah&#62;:&#60;blah&#62;;" field it&#39;s fine, but it doesn&#39;t solve my problem.</p>
<p>Please will someone post an example which shows how to do this? I&#39;ve recoded it about 50 times to no avail 🙁 - I&#39;ve tried using setColProp, setGridParam, $.get(&#39;/cgi-bin/blah&#39;) and onLoadComplete, and even tried specifying the url of the script in the editoptions: segment in the colModel, can&#39;t get it working.</p>
<p>Many thanks for your time and a great plugin!</p>
<p>Kind regs</p>
<p>Stew</p>
]]></description>
        	        	<pubDate>Mon, 23 Jun 2008 12:06:37 +0300</pubDate>
        </item>
</channel>
</rss>