<?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: jsonReader / reading "nonstandard" JSON</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/jsonreader-reading-nonstandard-json</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/jsonreader-reading-nonstandard-json/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>ronchalant on jsonReader / reading "nonstandard" JSON</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/jsonreader-reading-nonstandard-json#p24044</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/jsonreader-reading-nonstandard-json#p24044</guid>
        	        	<description><![CDATA[<p>I actually found a solution for this - adding ajaxGridOptions to my grid config options and using the dataFilter:</p>
<div id="sb34-L40" class="sourceRow ">ajaxGridOptions: {</div>
<div class="sourceRow ">&#160; dataFilter : function(data, type) {</div>
<div id="sb34-L42" class="sourceRow ">&#160; &#160; if (typeof(data) === &#39;string&#39; &#38;&#38; type === &#39;json&#39;) {</div>
<div id="sb34-L43" class="sourceRow">&#160; &#160; &#160; data = jQuery.parseJSON(data);</div>
<div id="sb34-L44" class="sourceRow">&#160; &#160; }</div>
<div class="sourceRow">&#160; &#160; return convert(data);</div>
<div id="sb34-L46" class="sourceRow">&#160; }</div>
<div id="sb34-L47" class="sourceRow">}</div>
</p>
<p>the "convert" function takes whatever I received from the AJAX call and converts it to the jqGrid standard with rows / cell / etc. &#160;The interesting thing is that regardless of setting the datatype to JSON it seems to always pass in and want returned a string value. &#160;So I have to parse the JSON string, convert to a new object, then stringify the converted object before returning it.</p>
]]></description>
        	        	<pubDate>Fri, 22 Jul 2011 23:39:32 +0300</pubDate>
        </item>
        <item>
        	<title>ronchalant on jsonReader / reading "nonstandard" JSON</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/jsonreader-reading-nonstandard-json#p24043</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/jsonreader-reading-nonstandard-json#p24043</guid>
        	        	<description><![CDATA[<p>Is there a way using the jsonReader or maybe with an event that a JSON object returned from an AJAX call can be translated into something the jqGrid can understand?</p>
</p>
<p>We have standard JSON objects gen&#39;d from data model classes that I can return sort of like this:</p>
</p>
<p>{</p>
<p>&#160; &#160;items: [</p>
<p>{ fname: &#39;Jon&#39;, lname: &#39;Doe&#39;, homeAddress: { address1: &#39;123 Main St.&#39;, city: &#39;Sometown&#39;, ... }, status: { id: 1, description: &#39;active&#39; } },</p>
<p>{ fname: &#39;Jane&#39;, lname: &#39;Doe&#39;, homeAddress: { address1: &#39;123 Main St.&#39;, city: &#39;Sometown&#39;, ... }, status: { id: 1, description: &#39;active&#39; } },</p>
<p>&#160;...</p>
<p>&#160; &#160;]</p>
<p>}</p>
</p>
<p>Which is totally non-conformant... is there a way/place I can inject a function in JS to convert it? &#160;I tried modifying the "success" function of the xhr via the loadBeforeSend(xhr) event, but it didn&#39;t like it.</p>
<p>I&#39;m using 3.8.2 for now, btw.</p>
]]></description>
        	        	<pubDate>Fri, 22 Jul 2011 23:13:53 +0300</pubDate>
        </item>
</channel>
</rss>