<?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: Show multiple selected options on Formedit mode</title>
	<link>http://www.trirand.com/blog/?page_id=393/discussion/show-multiple-selected-options-on-formedit-mode</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/discussion/show-multiple-selected-options-on-formedit-mode/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>Renso on Show multiple selected options on Formedit mode</title>
        	<link>http://www.trirand.com/blog/?page_id=393/discussion/show-multiple-selected-options-on-formedit-mode#p7537</link>
        	<category>Discussion</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/discussion/show-multiple-selected-options-on-formedit-mode#p7537</guid>
        	        	<description><![CDATA[<p>Not sure if I am doing something wrong but for the edittype:&#8221;select&#8221; col model property with editoptions:{multiple:true,size:4,value:allAccountRoles}, it does not select (highlight) the selected items in the listbox. It does show all the selectable options. No matter if I have one option or multiple options selected, it does not highlight them.</p>
<p>Here is my colModel <span class="sfcode">{name:&#39;AccountRole&#39;,&#160;&#160;&#160; index:&#39;AccountRole&#39;, width:40, editable:true, align:&#8221;left&#8221;, hidden:true, edittype:&#8221;select&#8221;, editoptions:{multiple:true,size:4,value:allAccountRoles}, editrules:{edithidden:true,required:true}}, </span><br />During loadComplete I then load the actual data into var allAccountRoles and setColProp appropriately (see below):</p>
<p><input type='button' class='sfcodeselect' name='sfselectit4951' value='Select Code' data-codeid='sfcode4951' /></p>
<div class='sfcode' id='sfcode4951'>loadComplete: function()&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; //get all Account Roles<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; allAccountRoles = $.ajax({url: $(&#39;#ajaxAllAccountRolesUrl&#39;).val(), async: false, success: function(data, result) {if (!result) alert(&#39;Failure to retrieve the Account Roles.&#39;);}}).responseText;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $(item).setColProp(&#39;AccountRole&#39;,{editoptions:{multiple:true,size:4,value:allAccountRoles}});</div>
<p>I perform this in many grids with no issues and is my modus operandi for al my grids as I perform ajax calls for the list data when I need it. I can see my data being loaded via the ajax call but for some reason it does not highlight the selected options</p>
<p>Here is the result of the ajax call that fecthes the list of account roles:</p>
<pre></pre>
<pre>1:Website Contact;2:Materials Contact;3:Lead Followup;4:Payment<br /><br />Here is the HTML definition of the column in the formedit (modal dialog):<span class="nodeLabelBox repTarget "><br /></span></pre>
<p><input type='button' class='sfcodeselect' name='sfselectit684' value='Select Code' data-codeid='sfcode684' /></p>
<div class='sfcode' id='sfcode684'>
<div class="nodeChildBox ">
<div class="nodeBox containerNodeBox  repIgnore  open selected">
<div class="nodeLabel "><span class="nodeLabelBox repTarget ">&#60;<span class="nodeTag ">select</span><span class="nodeAttr editGroup ">&#160;<span class="nodeName editable ">id</span>=&#8221;<span class="nodeValue editable ">AccountRole</span>&#8220;</span><span class="nodeAttr editGroup ">&#160;<span class="nodeName editable ">class</span>=&#8221;<span class="nodeValue editable ">FormElement</span>&#8220;</span><span class="nodeAttr editGroup ">&#160;<span class="nodeName editable ">multiple</span>=&#8221;&#8221;</span><span class="nodeAttr editGroup ">&#160;<span class="nodeName editable ">name</span>=&#8221;<span class="nodeValue editable ">AccountRole</span>&#8220;</span><span class="nodeAttr editGroup ">&#160;<span class="nodeName editable ">size</span>=&#8221;<span class="nodeValue editable ">4</span>&#8220;</span><span class="nodeBracket editable insertBefore ">&#62;</span></span></div>
<div class="nodeChildBox ">
<div class="nodeBox textNodeBox  repIgnore ">
<div class="nodeLabel "><span class="nodeLabelBox repTarget ">&#60;<span class="nodeTag ">option</span><span class="nodeAttr editGroup ">&#160;<span class="nodeName editable ">value</span>=&#8221;<span class="nodeValue editable ">1</span>&#8220;</span><span class="nodeBracket editable insertBefore ">&#62;</span><span class="nodeText editable ">Website Contact</span>&#60;/<span class="nodeTag ">option</span>&#62;</span></div>
</div>
<div class="nodeBox textNodeBox  repIgnore ">
<div class="nodeLabel "><span class="nodeLabelBox repTarget ">&#60;<span class="nodeTag ">option</span><span class="nodeAttr editGroup ">&#160;<span class="nodeName editable ">value</span>=&#8221;<span class="nodeValue editable ">2</span>&#8220;</span><span class="nodeBracket editable insertBefore ">&#62;</span><span class="nodeText editable ">Materials Contact</span>&#60;/<span class="nodeTag ">option</span>&#62;</span></div>
</div>
<div class="nodeBox textNodeBox  repIgnore ">
<div class="nodeLabel "><span class="nodeLabelBox repTarget ">&#60;<span class="nodeTag ">option</span><span class="nodeAttr editGroup ">&#160;<span class="nodeName editable ">value</span>=&#8221;<span class="nodeValue editable ">3</span>&#8220;</span><span class="nodeBracket editable insertBefore ">&#62;</span><span class="nodeText editable ">Lead Followup</span>&#60;/<span class="nodeTag ">option</span>&#62;</span></div>
</div>
<div class="nodeBox textNodeBox  repIgnore ">
<div class="nodeLabel "><span class="nodeLabelBox repTarget ">&#60;<span class="nodeTag ">option</span><span class="nodeAttr editGroup ">&#160;<span class="nodeName editable ">value</span>=&#8221;<span class="nodeValue editable ">4</span>&#8220;</span><span class="nodeBracket editable insertBefore ">&#62;</span><span class="nodeText editable ">Payment</span>&#60;/<span class="nodeTag ">option</span>&#62;</span></div>
</div>
</div>
<div class="nodeCloseLabel "><span class="nodeCloseLabelBox repTarget ">&#60;/<span class="nodeTag ">select</span>&#62;</span></div>
</div>
</div>
</div>
<p>I tried to set the col properties during both gridComplete and loadComplete, same result.<br />Not sure if it is not supported or a bug. I see in formedit.js, line 276:</p>
<p><input type='button' class='sfcodeselect' name='sfselectit8001' value='Select Code' data-codeid='sfcode8001' /></p>
<div class='sfcode' id='sfcode8001'>case &#8220;select-multiple&#8221;:<br /> postdata[this.name]= $(this).val();<br /> var selectedText = [];<br /> $(&#8221;option:selected&#8221;,this).each(<br /> function(i,selected){<br /> selectedText[i] = $(selected).text();<br /> }<br /> );<br /> extpost[this.name]= selectedText.join(&#8221;,&#8221;);<br />break;</div>
<pre></pre>
<pre>I notice that <span class="sourceRowText">postdata[this.name]</span> = $(this).val(), where the value of this.name = "AccountRole" and </pre>
<p>the <span class="sourceRowText">result of this.val() is an array of 2,3 (second and third options selected) :</span></p>
<pre><span class="objectBox objectBox-array "><span class="arrayLeftBracket ">[</span><span class="objectBox objectBox-string ">"2"</span><span class="arrayComma ">, </span><span class="objectBox objectBox-string ">"3"</span> 0=<span class="objectPropValue ">2</span> 1=<span class="objectPropValue ">3</span><span class="arrayRightBracket ">]</span></span></pre>
<p>. This works fine once I am already in the modal dialog mode, but the values once I close the edit mode and select to edit the row again does not highlight my selected options.</p>
<p>Any ideas?</p></p>
]]></description>
        	        	<pubDate>Mon, 29 Jun 2009 11:31:08 +0300</pubDate>
        </item>
</channel>
</rss>