<?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: onCellSelect and editCell can be called with ci=-1</title>
	<link>http://www.trirand.com/blog/?page_id=393/bugs/oncellselect-and-editcell-can-be-called-with-ci-1</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/oncellselect-and-editcell-can-be-called-with-ci-1/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>OlegK on onCellSelect and editCell can be called with ci=-1</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/oncellselect-and-editcell-can-be-called-with-ci-1#p31414</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/oncellselect-and-editcell-can-be-called-with-ci-1#p31414</guid>
        	        	<description><![CDATA[<p>Hello Tony,</p>
<p><strong>click</strong> event handler can be called with <strong>e.tagret</strong> which is DOM of <strong>tbody</strong>, <strong>tr</strong>, <strong>td</strong> or some sub-element of <strong>td</strong>. If one select a text in the grid using mouse then click event will be triggered on mouse up. So If one selects text of multiple rows of the grid then <strong>tbody</strong> will be <strong>e.tagret</strong>. If one select a text from multiple columns of one row then <strong>tr</strong> will be <strong>e.target</strong>. The case when <strong>e.target</strong> isÂ <strong>td</strong> or some sub-element of <strong>td</strong>Â is the most standard case.</p>
<p>The current implementation ofÂ <strong>click</strong> event handler contains <a href="https://github.com/tonytomov/jqGrid/blob/v4.6.0/js/grid.base.js#L2705" target="_blank">the line</a>Â </p>
<div class="sfcode">
<pre class="brush-javascript syntax">ptr = $(td,ts.rows).closest("tr.jqgrow");</pre></div><p>The next tests whetherÂ <strong>$(ptr).length === 0</strong> and makes <strong>return this;</strong>Â (which should be <strong>return;</strong> or <strong>return true;</strong> by the way). So the case whereÂ <strong>tbody</strong> will be <strong>e.tagret</strong>Â will be not a problem.</p>
<p>On the other side the case when <strong>tr</strong> will be <strong>e.target</strong>Â follow to setting <strong>ci=-1</strong> and <strong>tdHtml=undefined</strong> in <strong>the lines</strong>Â </p>
<div class="sfcode">
<pre class="brush-javascript syntax">ci = $.jgrid.getCellIndex(td);
tdHtml = $(td).closest("td,th").html();</pre></div><p>Â In the next lines the callbackÂ <strong>onCellSelect</strong> can be called with the values andÂ <strong>editCell</strong> can be called with <strong>ci=-1</strong>. It's a bug.</p>
<p>I suggest to insert the line</p>
<div class="sfcode">
<pre class="brush-javascript syntax">td = $(td).closest("tr.jqgrow&#62;td");</pre></div><p>before call ofÂ <strong>$.jgrid.getCellIndex</strong> and to use if <strong>td.length &#62; 0</strong> as additional criteria in the code below.</p>
<p>The exact changes ofÂ jqGrid code can be seen <a href="https://github.com/OlegKi/jqGrid/commit/c435f8d65eda7fe0bda98e7633c6aef94f0bc70b" target="_blank">here</a>.</p>
<p>Best regards<br />
 Oleg</p>
]]></description>
        	        	<pubDate>Fri, 28 Nov 2014 21:25:45 +0200</pubDate>
        </item>
</channel>
</rss>