<?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 formatter sometimes receives HTMLTableRowElement rather than rowData object</title>
	<link>http://www.trirand.com/blog/?page_id=393/bugs/custom-formatter-sometimes-receives-htmltablerowelement-rather-than-rowdata-object</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-formatter-sometimes-receives-htmltablerowelement-rather-than-rowdata-object/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>tluck01 on Custom formatter sometimes receives HTMLTableRowElement rather than rowData object</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/custom-formatter-sometimes-receives-htmltablerowelement-rather-than-rowdata-object#p25238</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/custom-formatter-sometimes-receives-htmltablerowelement-rather-than-rowdata-object#p25238</guid>
        	        	<description><![CDATA[<p>Hi,</p>
</p>
<p>I am using v4.2.0 and have discovered an issue with the column custom formatter function. &#160;It appears that it can be called with two different parameter types for the rowObject param under different circumstances. &#160;Here is the documentation link for the function: <a rel="nofollow" href="/jqgridwiki/doku.php?id=wiki:custom_formatter" target="_blank"></a><a href="http://www.trirand.com/jqgridw" rel="nofollow" target="_blank">http://www.trirand.com/jqgridw</a>....._formatter</p>
</p>
<p>The function is defined to conform to the following:</p>
</p>
<pre class="code javascript">function myformatter ( cellvalue, options, rowObject )
{
// format the cellvalue to new format
return new_formated_cellvalue;
}</pre>
<p> rowObject is supposed to be the data for the row, and when initally called always is.  However,  I am making the cell editable using using the select type in the colmodel definition like this:</p>
<pre class="code javascript"><p class="p1">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;{ 	name: &#39;state&#39;, &#160;</p><p class="p1">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; 	index: &#39;state&#39;,&#160;</p><p class="p1">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; 	editable: true, &#160;</p><p class="p1">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; 	edittype: &#39;select&#39;, &#160;</p><p class="p1">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; editoptions :&#160;</p><p class="p1">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; {</p>
<p class="p1">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; 	value : getSelectString()</p><p class="p1">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; },</p><p class="p1">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; formatter: 	function ( cellvalue, options, rowObject )</p>
<p class="p1">&#160; &#160; &#160; &#160; &#160; &#160; 			{</p><span style="white-space: pre;">					</span>return "new value";<br /><p class="p1">&#160; &#160; &#160; &#160; &#160; &#160; 			},</p>
<p class="p1">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; },&#160;</p></pre>
<p> The problem happens if I do the following: </p>
<ol>
<li>Start to edit the cell which creates a select object in the cell.</li>
<li>Hit "esc" to cancel the edit, making the select disappear.</li>
<li>At this point the formatter is called with a HTMLTableRowElement &#160;rather than a standard rowObject with the col values in it. &#160;</li>
</ol>
<p>The offending caller is in the "setCell" method at line 3117 in the jquery.jqGrid.src.js. &#160;Specifically, these lines seem to be at fault:</p>
<pre class="code javascript">var ind = $t.rows.namedItem(rowid);
if (ind){
var tcell = $("td:eq("+pos+")",ind);
if(nData !== "" &#124;&#124; forceupd === true) {
v = $t.formatter(rowid, nData, pos,ind,&#39;edit&#39;);
</pre>
</p>
<div class="  ">The "ind" variable is initialized as a HTMLTableRowElement (the result of the namedItem() call ), and will be sent as a param that be propagated through a few other methods and then passed to my formatter, which ultimately receives this HTMLTableRowElement rather than the proper rowData object.</div>
</p>
<div class="  ">The assumed proper behavior is what happens in "addCell" on line 977, where the formatter is called with the correct rowData object.</div>
</p>
<div class="  ">Thanks for any help.</div>
]]></description>
        	        	<pubDate>Fri, 25 Nov 2011 15:47:04 +0200</pubDate>
        </item>
</channel>
</rss>