<?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: Can't set selected item in a drop down list</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/cant-set-selected-item-in-a-drop-down-list</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/cant-set-selected-item-in-a-drop-down-list/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>tony on Can't set selected item in a drop down list</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/cant-set-selected-item-in-a-drop-down-list#p3908</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/cant-set-selected-item-in-a-drop-down-list#p3908</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>If this will resolve you problem - if you save the row we post the value to the server, but not the text. After saving we set the text again. Maybe you should not do anything.</p>
<p>(getRowData is NOT compatible when you edit the row)</p>
<p>Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Fri, 09 Jan 2009 08:21:22 +0200</pubDate>
        </item>
        <item>
        	<title>brad8118 on Can't set selected item in a drop down list</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/cant-set-selected-item-in-a-drop-down-list#p3898</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/cant-set-selected-item-in-a-drop-down-list#p3898</guid>
        	        	<description><![CDATA[<p>I think I understand what you&#39;re asking...</p>
<p>Here is the text used to create the select box in colModel (this works)</p>
<p>editoptions: { value: &#39;R &#160;:Rochester;MA &#160;:Massachusetts;DL &#160; &#160; &#160; &#160;:Data Librarian;Buff :Buffalo / &#160;Niagara Falls;Bing &#160;:Binghamton / Owego / Southern Tier;Other :All other locations;Alb:Albany and all points East;&#39;}</p>
<p>When I do this in the edit row function I get the following text.</p>
<p><span> </span>$("#list").editRow(rowNum.toString());</p>
<p>var dropDownData = $("#list").getRowData(rowNum).Location;</p>
<p>the value of dropDownData is&#160;</p>
<p>&#60;SELECT id=1_Location class=editable&#62;&#60;OPTION value="R &#160; &#160; &#160; &#160; "&#62;Rochester&#60;/OPTION&#62;&#60;OPTION value="MA &#160; &#160; &#160; &#160;"&#62;Massachusetts&#60;/OPTION&#62;&#60;OPTION value="DL &#160; &#160; &#160; &#160;"&#62;Data Librarian&#60;/OPTION&#62;&#60;OPTION value="Buff &#160; &#160; &#160;"&#62;Buffalo / &#160;Niagara Falls&#60;/OPTION&#62;&#60;OPTION value="Bing &#160; &#160; &#160;"&#62;Binghamton / Owego / Southern Tier&#60;/OPTION&#62;&#60;OPTION value="Other &#160; &#160; "&#62;All other locations&#60;/OPTION&#62;&#60;OPTION selected value="Alb &#160; &#160; &#160; "&#62;Albany and all points East&#60;/OPTION&#62;&#60;OPTION value=""&#62;&#60;/OPTION&#62;&#60;/SELECT&#62;</p>
<p>The dropdownList appears when I&#39;m editing the row. But I can&#39;t set the selected item. &#160;Everytime a user clicks the edit button the first item in the dropdownlist is always selected. &#160;I have the index and text of the item that needs to be selected. I just don&#39;t know how to do it.</p>
<p>I&#39;m assuming that i would use XXX.selectOptions(index, true); but I don&#39;t know how to get the XXX(ddl object) to use it on......</p>
<p>Understand my problem.</p></p>
]]></description>
        	        	<pubDate>Thu, 08 Jan 2009 14:17:14 +0200</pubDate>
        </item>
        <item>
        	<title>tony on Can't set selected item in a drop down list</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/cant-set-selected-item-in-a-drop-down-list#p3891</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/cant-set-selected-item-in-a-drop-down-list#p3891</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>If the text data is equal from those provided with the select this should work. Check to se if the data in edit options in colModel are the same as those in the grid.</p>
<p>Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Thu, 08 Jan 2009 10:13:06 +0200</pubDate>
        </item>
        <item>
        	<title>brad8118 on Can't set selected item in a drop down list</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/cant-set-selected-item-in-a-drop-down-list#p3884</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/cant-set-selected-item-in-a-drop-down-list#p3884</guid>
        	        	<description><![CDATA[<p>Inline. &#160;</p>
<p>🙂 - its awesome&#160;</p>
]]></description>
        	        	<pubDate>Thu, 08 Jan 2009 09:19:00 +0200</pubDate>
        </item>
        <item>
        	<title>tony on Can't set selected item in a drop down list</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/cant-set-selected-item-in-a-drop-down-list#p3883</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/cant-set-selected-item-in-a-drop-down-list#p3883</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>What you use inline edit, cell edit or form edit?</p>
<p>Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Thu, 08 Jan 2009 09:17:14 +0200</pubDate>
        </item>
        <item>
        	<title>brad8118 on Can't set selected item in a drop down list</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/cant-set-selected-item-in-a-drop-down-list#p3880</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/cant-set-selected-item-in-a-drop-down-list#p3880</guid>
        	        	<description><![CDATA[<p>Hey,</p>
<p>When I build the jqGrid I&#39;m creating a column that has a ddl(DropDownList) for each row.</p>
<p>Here is how the column is defined :&#160;</p>
<p>{ name: &#39;Location&#39;, index: &#39;Location&#39;, width: 90, editable: true, edittype: "select", editoptions: { value: &#39;R &#160;:Rochester;MA &#160;:Massachusetts;DL &#160; &#160; &#160; &#160;:Data Librarian;Buff :Buffalo / &#160;Niagara Falls;Bing &#160;:Binghamton / Owego / Southern Tier;Other :All other locations;Alb:Albany and all points East;&#39;}}]</p>
<p>When the grid is created dynamically the Location column contains a text of the item that should be selected.</p>
<p>When the user clicks the edit Row button, &#160;$("#list").editRow(rowNum); gets called and the ddl is displayed, as planned. &#160;I&#39;m having trouble trying to set the selected item. &#160;I know I can use&#160;$("#ddl").selectOptions(index", true);</p>
<p>BUT heres the issue &#160; I can&#39;t grab&#160;$("#ddl"). I don&#39;t know how to get the dom object from cell in the grid.</p>
<p>&#160;I used var locationData =&#160;$("#list").getRowData(rowNum).Location; But this returns the html that creates the ddl. &#160;ie&#160;</p>
<p>&#60;SELECT id=1_Location class=editable&#62;&#60;OPTION value="R &#160; &#160; &#160; &#160; "&#62;Rochester&#60;/OPTION&#62;&#60;OPTION selected value="MA &#160; &#160; &#160; &#160;"&#62;Massachusetts&#60;/OPTION&#62;&#60;OPTION value="DL &#160; &#160; &#160; &#160;"&#62;Data Librarian&#60;/OPTION&#62;&#60;OPTION value="Buff &#160; &#160; &#160;"&#62;Buffalo / &#160;Niagara Falls&#60;/OPTION&#62;&#60;OPTION value="Bing &#160; &#160; &#160;"&#62;Binghamton / Owego / Southern Tier&#60;/OPTION&#62;&#60;OPTION value="Other &#160; &#160; "&#62;All other locations&#60;/OPTION&#62;&#60;OPTION value="Alb &#160; &#160; &#160; "&#62;Albany and all points East&#60;/OPTION&#62;&#60;OPTION value=""&#62;&#60;/OPTION&#62;&#60;/SELECT&#62;</p>
</p>
<p>As a hack to get this to work I&#39;m doing this. I shouldn&#39;t need to parse the list every time and create a new ddl and set the selected item. &#160;I should be able to use the one that is created when the row is created.</p>
</p>
<p><span> </span>var locationSelect = document.createElement("select");</p>
<p><span> </span>var arrayLocations = (&#39;R &#160; &#160; &#160; &#160; :Rochester;MA &#160; &#160; &#160; &#160;:Massachusetts;DL &#160; &#160; &#160; &#160;:Data Librarian;Buff &#160; &#160; &#160;:Buffalo / &#160;Niagara Falls;Bing &#160; &#160; &#160;:Binghamton / Owego / Southern Tier;Other &#160; &#160; :All other locations;Alb &#160; &#160; &#160; :Albany and all points East;&#39;).split(";");</p>
<p><span> </span>for (var i = 0; i &#60; arrayLocations.length - 1; i++) {</p>
<p><span> </span>var optionItem = document.createElement("option");</p>
<p><span> </span>optionItem.value = trim(arrayLocations[i].split(":")[0]);</p>
<p><span> </span>optionItem.text = trim(arrayLocations[i].split(":")[1]);</p>
<p><span> </span>//check if this should be the selected item.</p>
<p><span> </span>if (arrayLocations[i].indexOf(rowData.Location) != -1)</p>
<p><span> </span>optionItem.selected = true;</p>
<p>locationSelect.add(optionItem);}</p>
</p>
<p>Any help would be awesome. &#160;</p>
<p>Thanks&#160;</p>
<p>Brad&#160;</p>
]]></description>
        	        	<pubDate>Thu, 08 Jan 2009 09:06:07 +0200</pubDate>
        </item>
</channel>
</rss>