<?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_value not called correctly when editing row in form</title>
	<link>http://www.trirand.com/blog/?page_id=393/bugs/custom_value-not-called-correctly-when-editing-row-in-form</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/custom_value-not-called-correctly-when-editing-row-in-form/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>Torge on custom_value not called correctly when editing row in form</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/custom_value-not-called-correctly-when-editing-row-in-form#p29421</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/custom_value-not-called-correctly-when-editing-row-in-form#p29421</guid>
        	        	<description><![CDATA[<p>Hi,</p>
<p>I created a JSFiddle which illustrates the problem:</p>
<p><a rel="nofollow" href="http://jsfiddle.net/gznMt/11/" target="_blank">http://jsfiddle.net/gznMt/11/</a></p>
</p>
<p>It should override the input value in the edit form with &#39;bla&#39; but does not do so, as the element passed to custom_value does not seem to exist.</p>
<p>As I already pointed out here: <a rel="nofollow" href="/blog/?page_id=393#29419" target="_blank"></a><a href="http://www.trirand.com/blog/?p&#038;hellip" rel="nofollow" target="_blank"><a href="http://www.trirand.com/blog/?p" rel="nofollow">http://www.trirand.com/blog/?p</a>.....038;hellip</a>;..=393#29419</p>
<p>I think the bug is that custom_value is called before the form is attached to the table body.</p>
<p>A workaround seems to be to replace this code in createData:</p>
</p>
<div id="sfcode1141" class="sfcode">if($.isFunction(opt.custom_value) &#38;&#38; rowid !== "_empty" ) {<br />&#160;&#160; &#160; opt.custom_value.call($t, $("#"+nm,"#"+frmgr),&#39;set&#39;,tmp);<br />}</div>
</p>
<p>With this:</p>
<div id="sfcode3155" class="sfcode">if($.isFunction(opt.custom_value) &#38;&#38; rowid !== "_empty" ) {<br />&#160;&#160;&#160;&#160; opt.custom_value.call($t, $("#"+nm,tb),&#39;set&#39;,tmp);<br />}</div>
</p>
<p>Or am I not getting something? Then please provide me with a fixed JSFiddle <img class="wp-smiley" src="/blog/wp-includes/images/smilies/icon_smile.gif" alt=":)" /></p>
</p>
<p>Greetings,</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Torge.</p>
</p>
<p>Update: <br />For everyone with the same problem. I found a workaround without patching the jquery code.</p>
<p>custom_value : function(elem, operation, value) {</p>
<p>&#160;&#160;&#160;&#160; if ($(elem).length == 0) return;</p>
<p>&#160;&#160;&#160;&#160; ... Do your stuff ...<br />}</p>
<p>This works becuase in these cases custom_element already has been called and was able to set the value correctly. In other cases the Form is already attached to the table and the elem object is pointing to it correctly.</p>
]]></description>
        	        	<pubDate>Thu, 29 Aug 2013 15:25:00 +0300</pubDate>
        </item>
</channel>
</rss>