<?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: After calling reloadGrid pager stops sending paging information. </title>
	<link>http://www.trirand.com/blog/?page_id=393/help/after-calling-reloadgrid-pager-stops-sending-paging-information</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/after-calling-reloadgrid-pager-stops-sending-paging-information/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>mscherzer on After calling reloadGrid pager stops sending paging information. </title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/after-calling-reloadgrid-pager-stops-sending-paging-information#p30066</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/after-calling-reloadgrid-pager-stops-sending-paging-information#p30066</guid>
        	        	<description><![CDATA[<p>I have now worked around this issue.</p>
<p>What I think is was happening is that when I set the postData option I was overriding the fields set by the pager.</p>
<p>As  a work around I build a little helper method that grabs the  existing  postData that also contains the pager fields and then I just  appends my  data to it.</p>
<p>This now works for me but I can&#39;t help wondering if there is not a neater way to do this?</p>
</p>
<p>The following code may or may not be usefull to someone else trying to do the same thing.</p>
<p>This is the helper method that turns the fields in an external form into an object that can be passed to the postData option.</p>
<p>The  method expects a jquery selector to find the form that is to be  posted  on every request. The method is also passed an existing postData  object  that is merged with the values retrieved from the form fields.</p>
<p>+++++++++++++++++++++++++++++++++++++++++++++++</p>
<p>function objectFromForm(selector,extraData)<br />&#160;&#160; &#160;&#160;&#160; &#160;{<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;var source,target;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;source = $(selector).serializeArray();<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;target = {};<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;/* Turn the form into an object. Values for duplicate key names are added as a comma seperated values. */<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;$.each(source,function(i,item) <br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;var key,value;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;key = item.name.toLowerCase();<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;value = item.value;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;if(key in target)<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;value = target[key] + "," + value;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;}<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;target[key] = value;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;});<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;/* Append extraData to form (extraData does NOT override form fields.) */<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;$.each(extraData,function(key,item) <br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;if(!(key in target))<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;target[key] = item;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;}<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;});<br />&#160;&#160; &#160;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;return target;<br />&#160;&#160; &#160;&#160;&#160; &#160;}</p>
<p>+++++++++++++++++++++++++++++++++++++++++++++++</p>
</p>
<p>The  following code is then added to the beforeRequest handler. Now  after  every request the current form is also submitted including all  the  relevant paging information. One stupid thing in this  implementation is  that checkboxes and other form elements that don&#39;t  get posted when they  are unchecked must be manually removed. So changes  to the form require  changed to this code. 🙁</p>
</p>
<p>beforeRequest:function()<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;var postData, formData;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;/* We need to do this to persist the paging data accross requests. */<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;postData = $(&#39;#resultGrid&#39;).getGridParam("postData");&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;/* <br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;We need to remove any form elements that are not submitted if empty. checkboxes, radio fields etc.<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;Without this code any set values will never be unset on subsequent requests. <br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;*/<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;delete postData["purchaseorderid"];<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;formData = objectFromForm("#frmFilter",postData);<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;$(&#39;#resultGrid&#39;).setGridParam({postData:formData});<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;}</p>
]]></description>
        	        	<pubDate>Thu, 09 Jan 2014 05:39:07 +0200</pubDate>
        </item>
        <item>
        	<title>mscherzer on After calling reloadGrid pager stops sending paging information. </title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/after-calling-reloadgrid-pager-stops-sending-paging-information#p30063</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/after-calling-reloadgrid-pager-stops-sending-paging-information#p30063</guid>
        	        	<description><![CDATA[<p>Hi,<br />I have a hit a stump in my attempt to integrate jqGrid hopefully someone can point me in the right direction. </p>
<p>When I first load my html page everything works as expected until I reload the grid with: trigger(&#39;reloadGrid&#39;). After the reload the pager stops sending any of the paging information in subsequent requests.</p>
<p>Anyone got any ideas what I am doing wrong? Do I have to also somehow reinit the pager? </p>
<p>Quick summary of what I am doing:</p>
<p>1) Need to communicate with our server only using POST requests.<br />2) Our search form can not be the one provided by the jqGrid search functionality.<br />3) When a user clicks the search button on our search form, the form fields are copied to a struct of name:value pairs which are then added to the postData option after which we call trigger(&#39;reloadGrid&#39;). </p>
<p>Code snippet:</p>
<p>data =<br />{<br />&#160;&#160;&#160; API_FUNCTION:"DO_MY_SEARCH",<br />&#160;&#160; &#160;hint:"OPEN_ITEMS",<br />&#160;&#160; &#160;userID:$("#supplierID").val(),<br />&#160;&#160; &#160;description:$("#description").val()<br />};<br />$(&#39;#resultGrid&#39;).setGridParam({postData:data});<br />$(&#39;#resultGrid&#39;).trigger(&#39;reloadGrid&#39;);</p>
<p>Everything works as expected except the "Pager" which breaks as soon as the grid is reloaded. Clicking the pager buttons still request data from the server with the correct search fields just without any of the pager data. (page, rows etc.) As stated before when the grid is first initialised the pager passed all its fields as exepected.</p>
<p>Anyone got any ideas?</p>
<p>cheers</p>
<p>Marcel</p>
]]></description>
        	        	<pubDate>Wed, 08 Jan 2014 17:10:26 +0200</pubDate>
        </item>
</channel>
</rss>