<?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: dataInit can be called with number as parameter</title>
	<link>http://www.trirand.com/blog/?page_id=393/bugs/datainit-can-be-called-with-number-as-parameter</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/datainit-can-be-called-with-number-as-parameter/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>tony on dataInit can be called with number as parameter</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/datainit-can-be-called-with-number-as-parameter#p26301</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/datainit-can-be-called-with-number-as-parameter#p26301</guid>
        	        	<description><![CDATA[<p>Thanks Oleg.</p>
</p>
<p>Fixed.</p>
]]></description>
        	        	<pubDate>Thu, 05 Apr 2012 13:05:48 +0300</pubDate>
        </item>
        <item>
        	<title>OlegK on dataInit can be called with number as parameter</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/datainit-can-be-called-with-number-as-parameter#p26286</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/datainit-can-be-called-with-number-as-parameter#p26286</guid>
        	        	<description><![CDATA[<p>Hello Tony,</p>
<p>I exanined strange problem where <strong>dataInit</strong> was called multiple times: one time with <em>Number</em> as parameter like 0 (???) and the second time with DOM element as parameter. Because the code like <strong>$(0).datepicker()</strong> produce no exception typical code work correctly, but other kind of usage of input parameter can follow to error.</p>
<p>The reason of the strange behavior is in the line of <strong>setAttributes</strong> function from the <em>grid.common.js</em> module. <a href="https://github.com/tonytomov/jqGrid/blob/v4.3.1/js/grid.common.js#L284" target="_blank">The line</a></p>
<p><input type='button' class='sfcodeselect' name='sfselectit8073' value='Select Code' data-codeid='sfcode8073' /></p>
<div class='sfcode' id='sfcode8073'>exclude = $.extend(exclude, exl);</div>
<p>will be used to merge <strong>exl</strong> array with the array holding some standard attributes</p>
<p><input type='button' class='sfcodeselect' name='sfselectit6198' value='Select Code' data-codeid='sfcode6198' /></p>
<div class='sfcode' id='sfcode6198'>var exclude = [&#39;dataInit&#39;,&#39;dataEvents&#39;,&#39;dataUrl&#39;, &#39;buildSelect&#39;,&#39;sopt&#39;, &#39;searchhidden&#39;, &#39;defaultValue&#39;, &#39;attr&#39;];</div>
<p>The problem is that <strong>$.extend</strong>&#160;<span style="text-decoration: underline;">don&#39;t work with arrays</span> and in case of <strong>exl=[&#39;value&#39;]</strong> for example (see <a href="https://github.com/tonytomov/jqGrid/blob/v4.3.1/js/grid.common.js#L331" target="_blank">the line</a>) replace first elements instead of merging. In the example with <strong>[&#39;value&#39;]</strong>&#160;one get</p>
<p><input type='button' class='sfcodeselect' name='sfselectit5939' value='Select Code' data-codeid='sfcode5939' /></p>
<div class='sfcode' id='sfcode5939'>[<strong>&#39;value&#39;</strong>,&#39;dataEvents&#39;,&#39;dataUrl&#39;, &#39;buildSelect&#39;,&#39;sopt&#39;, &#39;searchhidden&#39;, &#39;defaultValue&#39;, &#39;attr&#39;]</div>
<p>&#160;instead of</p>
<p><input type='button' class='sfcodeselect' name='sfselectit1841' value='Select Code' data-codeid='sfcode1841' /></p>
<div class='sfcode' id='sfcode1841'>[&#39;dataInit&#39;,&#39;dataEvents&#39;,&#39;dataUrl&#39;, &#39;buildSelect&#39;,&#39;sopt&#39;, &#39;searchhidden&#39;, &#39;defaultValue&#39;, &#39;attr&#39;, &#39;value&#39;]</div>
<p>As the result the line <a href="https://github.com/tonytomov/jqGrid/blob/v4.3.1/js/grid.common.js#L288" target="_blank">$(elm).attr(key,value);</a> will be used for <strong>dataInit</strong>&#160;and the function will be called with wrong parameter.</p>
<p>To fix the problem one should just replace the line</p>
<p><input type='button' class='sfcodeselect' name='sfselectit5107' value='Select Code' data-codeid='sfcode5107' /></p>
<div class='sfcode' id='sfcode5107'>exclude = $.extend(exclude, exl);</div>
<p>to the line</p>
<p><input type='button' class='sfcodeselect' name='sfselectit7898' value='Select Code' data-codeid='sfcode7898' /></p>
<div class='sfcode' id='sfcode7898'><strong>$.merge(exclude, exl);</strong></div>
<p>Best regards<br />Oleg</p></p>
]]></description>
        	        	<pubDate>Tue, 03 Apr 2012 22:37:54 +0300</pubDate>
        </item>
</channel>
</rss>