<?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: Getting full set of JS-sorted data .. </title>
	<link>http://www.trirand.com/blog/?page_id=393/feature-request/getting-full-set-of-js-sorted-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/feature-request/getting-full-set-of-js-sorted-data/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>ronchalant on Getting full set of JS-sorted data .. </title>
        	<link>http://www.trirand.com/blog/?page_id=393/feature-request/getting-full-set-of-js-sorted-data#p24913</link>
        	<category>Feature Request</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/feature-request/getting-full-set-of-js-sorted-data#p24913</guid>
        	        	<description><![CDATA[<p>We use jqGrid extensively, and one of the things we often do is have homegrown jQuery widgets appear as lightboxes or dialogs after being clicked on in a grid containing updatable forms for the selected record.  Our grids are paged; we don&#39;t use updatable grids because the data itself is very extensive and we only show a subset of the record in the form for browsing.</p>
<p>What we recently wanted to add to these widgets is the ability to go forward and backward in the list of records. So say I have a list of 80 records and I show 20 per page; if I click on the first one to bring up a detail widget, a "Next" button would be available and clicking on it would get the ID of the next record and load that into the widget.</p>
<p>What we found in doing this however is that the jqGrid plugin only readily allows access to the IDs that are in the current page, even when we use loadonce.  We could do some hacking around and have the rowNum changed to some large value, pull the data out, then change it back, but that seems like a lot of overhead.  Intercepting the data from the original Ajax call or load events before the records are sliced doesn&#39;t work because  of sorting - when the data is sorted it appears that it&#39;s only available as a full sorted list of objects very briefly in the addLocalData function.</p>
<p>What I ended up doing is adding a custom "event" in my code called onSortComplete, which passes this full sorted data from the sort query to the event handler when present.  In my local copy of the 4.2.0 jqGrid this is around line 1550, right before this:</p>
<pre>// added: event that passes the sorted list
if ($.isFunction(ts.p.onSortComplete)) {
	try { ts.p.onSortComplete.call(ts, queryResults); }
	catch (e) { }
}

queryResults = queryResults.slice( (page-1)*recordsperpage , page*recordsperpage );</pre>
<p>I don&#39;t know if this makes sense to add in, or consider at least.  And I only use it for my "loadonce" style grids that I do client-side sorting on.  But it was helpful to me, so I wanted to post it here.</p>
]]></description>
        	        	<pubDate>Mon, 17 Oct 2011 22:58:07 +0300</pubDate>
        </item>
</channel>
</rss>