<?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: Formatter Select and JSON data</title>
	<link>http://www.trirand.com/blog/?page_id=393/discussion/formatter-select-and-json-data</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/formatter-select-and-json-data/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>Seawinnie on Formatter Select and JSON data</title>
        	<link>http://www.trirand.com/blog/?page_id=393/discussion/formatter-select-and-json-data#p28532</link>
        	<category>Discussion</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/discussion/formatter-select-and-json-data#p28532</guid>
        	        	<description><![CDATA[<p>HI,</p>
</p>
<p>i have a grid that is populated by JSON data with the last column of the grid (ProjectID) using a select for editing. The select correctly displays the display value in the edit form, however on the grid the id value is displayed.</p>
<p>I have tried setting formatter:&#39;select&#39; on the column but this causes blank values to be displayed rather than the ids. Is there something else I need to do to display the text value in the grid? I am using buildSelect on the column, is this casuing an issue? I have provided my jqgrid data below and have confirmed that valid json data is returned for both the grid and the select.</p>
</p>
<p>Any help would be much appreciated. Thanks</p>
</p>
<p>$("#list").jqGrid({</p>
<p>url:&#39;HR_GridTemplate_Datahandler.asp?status=GetSkills&#39;,</p>
<p>datatype: "json",</p>
<p>colNames:[&#39;Id&#39;,&#39;Skill Name&#39;, &#39;Skill Description&#39;,&#39;Status&#39;,&#39;Completion Plus Years&#39;,&#39;Reminder&#39;,&#39;Project&#39;],</p>
<p>colModel:[</p>
<p>{name:&#39;Id&#39;, index:&#39;Id&#39;, key:true, sorttype:&#39;int&#39;, hidden: true, editable:false},</p>
<p>{name:&#39;SkillName&#39;, index:&#39;SkillName&#39;, width:350, editable:true,editoptions:{size:"100",maxlength:"150"}},</p>
<p>{name:&#39;SkillDescription&#39;, index:&#39;SkillDescription&#39;, width:350, align:&#39;left&#39;, editable:true,editoptions:{size:"100",maxlength:"300"}},</p>
<p>{name:&#39;active&#39;, index:&#39;active&#39;,  align:&#39;left&#39;, editable:true,edittype:"select", editoptions:{value:"Active:Active;Archive:Archive"}},</p>
<p>{name:&#39;CompletionPlusYears&#39;, index:&#39;CompletionPlusYears&#39;, editable:true,edittype:"select", editoptions:{value:":;0:0;1:1;1.5:1.5;2:2;2.5:2.5;3:3;3.5:3.5;4:4;4.5:4.5;5:5;6:6;7:7;8:8;9:9;10:10"}},</p>
<p>{name:&#39;Reminder&#39;, index:&#39;Reminder&#39;, align:&#39;right&#39;, editable:true,edittype:"select", editoptions:{value:"Yes:Yes;No:No"}},</p>
<p>{<span style="color: #ff0000;">name:&#39;ProjectID&#39;, edittype:&#39;select&#39;, formatter:&#39;select&#39;,</span></p>
<p>editoptions: { dataUrl:"HR_GridTemplate_Datahandler.asp?status=GetProjects",</p>
<p>buildSelect: function(data)</p>
<p style="padding-left: 60px;">{</p>
<p style="padding-left: 60px;"><span style="white-space: pre;"> </span>var response = jQuery.parseJSON(data);</p>
<p style="padding-left: 60px;"><span style="white-space: pre;"> </span>var s = &#39;&#60;select&#62;&#39;;</p>
<p style="padding-left: 60px;"><span style="white-space: pre;"> </span>jQuery.each(response, function(i, item) {</p>
<p style="padding-left: 60px;"><span style="white-space: pre;"> </span>s += &#39;&#60;option value="&#39;+response[i].id+&#39;"&#62;&#39;+response[i].name+&#39;&#60;/option&#62;&#39;;</p>
<p style="padding-left: 60px;"><span style="white-space: pre;"> </span>});</p>
<p style="padding-left: 60px;"><span style="white-space: pre;"> </span>return s + "&#60;/select&#62;";</p>
<p style="padding-left: 60px;">}</p>
<p>}</p>
<p>}</p>
<p>],</p>
<p>height:&#39;auto&#39;,</p>
<p>width: &#39;auto&#39;,</p>
<p>pager: &#39;#skillpager&#39;,</p>
<p>rowNum:25,</p>
<p>rowList:[10,25,50,100,200,500],</p>
<p>sortname: &#39;SkillName&#39;,</p>
<p>sortorder: "desc",</p>
<p>// Checkbox to multi select</p>
<p>multiselect: true,</p>
<p>loadonce: true,</p>
<p>jsonReader: {</p>
<p>repeatitems: false,</p>
<p>root: function (obj) { return obj; },</p>
<p>page: function (obj) { return $("#list").jqGrid(&#39;getGridParam&#39;, &#39;page&#39;); },</p>
<p>total: function (obj) { return Math.ceil(obj.length / $("#list").jqGrid(&#39;getGridParam&#39;, &#39;rowNum&#39;)); },</p>
<p>records: function (obj) { return obj.length; }</p>
<p>},</p>
<p>viewrecords: true,</p>
<p>caption: "Skills Grid",</p>
<p>ignoreCase:true,</p>
<p>ondblClickRow: function(rowid) {</p>
<p>jQuery(this).jqGrid(&#39;editGridRow&#39;, rowid,</p>
<p>{recreateForm:true,closeAfterEdit:true,</p>
<p>closeOnEscape:true,reloadAfterSubmit:false,width:700,top:200,left:200});</p>
<p>}</p>
<p>});</p></p>
]]></description>
        	        	<pubDate>Wed, 27 Mar 2013 02:47:34 +0200</pubDate>
        </item>
</channel>
</rss>