<?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: Custom functions (addfunc, etc.), Getting reference to grid dynamically</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/custom-functions-addfunc-etc-getting-reference-to-grid-dynamically</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/custom-functions-addfunc-etc-getting-reference-to-grid-dynamically/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>George H. on Custom functions (addfunc, etc.), Getting reference to grid dynamically</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/custom-functions-addfunc-etc-getting-reference-to-grid-dynamically#p21248</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/custom-functions-addfunc-etc-getting-reference-to-grid-dynamically#p21248</guid>
        	        	<description><![CDATA[<p>I never paid attention to your status and just assumed you had moderator access. I will post into the bug forums.</p>
<p>Thanks for your help. Keep up the good work.</p>
]]></description>
        	        	<pubDate>Fri, 10 Dec 2010 20:24:09 +0200</pubDate>
        </item>
        <item>
        	<title>OlegK on Custom functions (addfunc, etc.), Getting reference to grid dynamically</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/custom-functions-addfunc-etc-getting-reference-to-grid-dynamically#p21247</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/custom-functions-addfunc-etc-getting-reference-to-grid-dynamically#p21247</guid>
        	        	<description><![CDATA[<p>George,</p>
<p>first of all like you can see on the left side my status is "Member" like youth and not "Moderator" like the status of Tony, the developer of jqGrid. So I can not move your report if you can not do this. In the "Help" part of the forum some develpers who use jqGrid help other developers. So I suggested to post your suggestion in the "Bugs" forum to be sure that Tony read it and probably make the changes.</p>
<p>I send you the url to of the place of the source where you can see that Add button has "ui-icon-plus" as the icon. So the code like</p>
<p><input type='button' class='sfcodeselect' name='sfselectit5680' value='Select Code' data-codeid='sfcode5680' /></p>
<div class='sfcode' id='sfcode5680'>$(&#34;#list&#34;).jqGrid (&#39;navButtonAdd&#39;, &#39;#pager&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; { caption: &#34;&#34;, buttonicon: &#34;ui-icon-plus&#34;, title: &#34;Add new row&#34;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; onClickButton: function() {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var rowid = grid.jqGrid(&#39;getGridParam&#39;, &#39;selrow&#39;);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; alert (&#34;add operation with the rowid=&#34;+rowid);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />});</div>
<p>includes the same button as the original Add button.</p>
<p>Best regards<br />Oleg</p>
]]></description>
        	        	<pubDate>Fri, 10 Dec 2010 20:15:30 +0200</pubDate>
        </item>
        <item>
        	<title>George H. on Custom functions (addfunc, etc.), Getting reference to grid dynamically</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/custom-functions-addfunc-etc-getting-reference-to-grid-dynamically#p21246</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/custom-functions-addfunc-etc-getting-reference-to-grid-dynamically#p21246</guid>
        	        	<description><![CDATA[<p>Oleg</p>
<p>Yes, you&#39;re correct, the <strong>o.addfunc.call($t)</strong> would make more sense. I am aware of the custom button option and initially implemented it, but I wasn&#39;t happy with the button placement / look so that prompted me to browse the source where I found the undocumented addfunc, etc. calls. Implementing the custom addfunc90 seemed like a better option since the buttons were easily enabled / disabled and located in the correct position without having to tweak the ui, etc. I will make the changes you suggested with the assumption that the next release of jqGrid will implement them where <em>this</em> refers to the grid.</p>
<p>How do you want me to repost this in Bugs? Or can you just move this topic / thread into the bugs part of the forum? That would seem easier.</p>
<p>Thanks<br />George</p></p>
]]></description>
        	        	<pubDate>Fri, 10 Dec 2010 19:23:33 +0200</pubDate>
        </item>
        <item>
        	<title>OlegK on Custom functions (addfunc, etc.), Getting reference to grid dynamically</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/custom-functions-addfunc-etc-getting-reference-to-grid-dynamically#p21245</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/custom-functions-addfunc-etc-getting-reference-to-grid-dynamically#p21245</guid>
        	        	<description><![CDATA[<p>Hello George,</p>
<p>You are right, that it would be better to set this for the most callback functions. jqGrid in last versions made the corresponding changes in the most places, but not here. The usage of <strong>o.addfunc.call($t)</strong>&#160;instead of <strong>o.addfunc($t)</strong>&#160;seems me better because it set only <em>this</em>. If you want you can post the corresponding to "bugs" part of the forum.</p>
<p>If you need a solution now you can use <a href="/jqgridwiki/doku.php?id=wiki:custom_buttons" target="_blank">custom button</a> which look like the&#160;standard&#160;Add/Edit or Delete button and which has the same icon as the the original (see <a href="https://github.com/tonytomov/jqGrid/blob/master/js/grid.formedit.js#L1596" target="_blank">the source code</a> of navGrid&#160;for details).&#160;</p>
<p>Best regards<br />Oleg</p>
]]></description>
        	        	<pubDate>Fri, 10 Dec 2010 18:57:20 +0200</pubDate>
        </item>
        <item>
        	<title>George H. on Custom functions (addfunc, etc.), Getting reference to grid dynamically</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/custom-functions-addfunc-etc-getting-reference-to-grid-dynamically#p21243</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/custom-functions-addfunc-etc-getting-reference-to-grid-dynamically#p21243</guid>
        	        	<description><![CDATA[<p>The same would probably need to be done for the editfunc and delfunc:</p>
<p>&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160;&#160; if(typeof o.editfunc == &#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;&#160;&#160;&#160; o.editfunc(sr, $t);<br />&#160;&#160; &#160;&#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;&#160;&#160; &#160;$($t).jqGrid("editGridRow",sr,pEdit);</p>
<p>&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;}</p>
<p>&#160; &#160; &#160; &#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; ...</p>
<p>&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160;&#160; if("function" == typeof o.delfunc){<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;o.delfunc(dr, $t);<br />&#160;&#160; &#160;&#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;&#160;&#160; &#160;$($t).jqGrid("delGridRow",dr,pDel);<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;}</p>
<p>Although my requirements don&#39;t need it, applying the above to the beforeRefresh and afterRefresh might be warranted for API consistency:</p>
<p>&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160;&#160; if (o.refresh) {<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; ...</p>
<p>&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160;&#160; if($.isFunction(o.beforeRefresh)) { o.beforeRefresh($t); }<br />&#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; if($.isFunction(o.afterRefresh)) { o.afterRefresh($t); }<br />&#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; }</p></p>
]]></description>
        	        	<pubDate>Fri, 10 Dec 2010 16:58:49 +0200</pubDate>
        </item>
        <item>
        	<title>George H. on Custom functions (addfunc, etc.), Getting reference to grid dynamically</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/custom-functions-addfunc-etc-getting-reference-to-grid-dynamically#p21234</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/custom-functions-addfunc-etc-getting-reference-to-grid-dynamically#p21234</guid>
        	        	<description><![CDATA[<p>Thanks for the GREAT product! Nice work.</p>
<p>I&#39;m working on a custom implementation of the "undocumented" addfunc property for the NavGrid. Looking at the code that calls the user-defined addfunc (jqgrid.formedit.js):</p>
<p>&#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;})<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;<br />No parameters are passed into the user-defined function. However inside of my custom implementation for addfunc, I need to be able to reference the grid (automatic insert of new data or force entire grid to refresh, etc.). Inside the addfunc implementation, &#39;this&#39; references the NavGrid object and I&#39;m unable to find a way to reference the parent object (without using the #id attribute which as previously stated is dynamically generated and unknown at runtime). My solution to the problem was to modify the call to addfunc() so that the grid object is passed in as a parameter:</p>
<p>&#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($t);<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>
<p>That immediately solves my needs, however those customizations make it more difficult to upgrade jqGrid at a future date. Am I missing something (i.e. a way to reference the grid without knowing the #id) or can these changes be made upstream for future releases?</p>
<p>Hopefully I&#39;m just being a jQuery/javascript novice and there is a simple solution.</p>
<p>Thanks<br />George</p>
]]></description>
        	        	<pubDate>Fri, 10 Dec 2010 04:21:22 +0200</pubDate>
        </item>
</channel>
</rss>