<?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: jqgrid.formedit: addfunc(), editfunc(), delfunc() - Pass jqGrid reference</title>
	<link>http://www.trirand.com/blog/?page_id=393/bugs/jqgrid-formedit-addfunc-editfunc-delfunc-pass-jqgrid-reference</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/bugs/jqgrid-formedit-addfunc-editfunc-delfunc-pass-jqgrid-reference/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>George H. on jqgrid.formedit: addfunc(), editfunc(), delfunc() - Pass jqGrid reference</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/jqgrid-formedit-addfunc-editfunc-delfunc-pass-jqgrid-reference#p21249</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/jqgrid-formedit-addfunc-editfunc-delfunc-pass-jqgrid-reference#p21249</guid>
        	        	<description><![CDATA[<p>Please reference the following help request for additional information:</p>
<p><a href="http://www.trirand.com/blog/?page_id=393/help/custom-functions-addfunc-etc-getting-reference-to-grid-dynamically/" rel="nofollow" target="_blank"><a href="http://www.trirand.com/blog/?p" rel="nofollow">http://www.trirand.com/blog/?p</a>.....namically/</a></p>
<p>Can the undocumented <strong>addfunc()</strong>, <strong>editfunc()</strong>, <strong>delfunc()</strong> functions in <span style="text-decoration: underline;">jqgrid.formedit.js</span> be modified so that <em>this</em> references the actual jqGrid object. Inside the user-defined function, <em>this</em> currently references the NavGrid option without the ability to programmatically reference the parent/containing jqGrid item. In a custom <strong>addfunc()</strong>, you could potentially need access to the jqGrid item to call the appropriate refresh or data synchronization commands. For my implementation, the jqGrid #id is dynamically generated at the server side so I don&#39;t have easy access to reference the grid traditionally (i.e. <em>$(#id).jqGrid({});</em>)</p>
<p>The existing code snippet (just <strong>addfunc()</strong> listed for brevity):</p>
<p>&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160; .click(function(){<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;if (typeof o.addfunc == &#39;function&#39;) {<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;o.addfunc();<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;} else {<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;$($t).jqGrid("editGridRow","new",pAdd);<br />&#160;&#160; &#160;&#160;&#160; &#160;&#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;&#160;&#160; &#160;return false;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;})</p>
<p>would become:</p>
<p>&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160; .click(function(){<br /> &#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;if (typeof o.addfunc == &#39;function&#39;) {<br /> &#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;<span style="color: #ff0000;"><strong>o.addfunc.call($t);</strong></span><br /> &#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;} else {<br /> &#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;$($t).jqGrid("editGridRow","new",pAdd);<br /> &#160;&#160; &#160;&#160;&#160; &#160;&#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;&#160;&#160; &#160;return false;<br /> &#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;})</p>
<p>The same logic can be applied to the <strong>beforeRefresh()</strong> and <strong>afterRefresh()</strong> user-defined functions calls as well for consistency. If <em>this</em> is supposed to reference the NavGrid option, can the grid reference be passed as a function parameter? (i.e. <strong>o.addfunc($t)</strong>).</p>
<p>I can supply a DIFF patch from the latest version if you prefer although all of the requested changes are relatively minor.</p>
<p>Thanks!<br />George</p>
]]></description>
        	        	<pubDate>Fri, 10 Dec 2010 20:43:28 +0200</pubDate>
        </item>
</channel>
</rss>