<?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: small bug fixes in jquery.contextmenu.js plugin</title>
	<link>http://www.trirand.com/blog/?page_id=393/bugs/small-bug-fixes-in-jquery-contextmenu-js-plugin</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/small-bug-fixes-in-jquery-contextmenu-js-plugin/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>OlegK on small bug fixes in jquery.contextmenu.js plugin</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/small-bug-fixes-in-jquery-contextmenu-js-plugin#p25365</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/small-bug-fixes-in-jquery-contextmenu-js-plugin#p25365</guid>
        	        	<description><![CDATA[<p>Hello Tony,</p>
<p>The next problem in the context menu that it returns always false from the contextmenu event (see <a href="https://github.com/tonytomov/jqGrid/blob/v4.2.0/plugins/jquery.contextmenu.js#L82" target="_blank">here</a>). I suggest to make the following small modification in the code</p>
<p><input type='button' class='sfcodeselect' name='sfselectit1758' value='Select Code' data-codeid='sfcode1758' /></p>
<div class='sfcode' id='sfcode1758'>$(this).bind(&#39;contextmenu&#39;, function(e) {<br />&#160; // Check if onContextMenu() defined<br />&#160; var bShowContext = (!!hash[index].onContextMenu) ? hash[index].onContextMenu(e) : true;<br />&#160; currentTarget = e.target;<br />&#160; if (bShowContext) <strong>{</strong><br />&#160; &#160; display(index, this, e, options);<br />&#160; &#160; <strong>return false;</strong><br />&#160; <strong>}</strong><br />});&#160;</div>
<p>You can find additional information in <a href="http://stackoverflow.com/a/8460480/315935" target="_blank">the answer</a>.</p>
<p>Best regards<br />Oleg&#160;</p></p>
]]></description>
        	        	<pubDate>Sun, 11 Dec 2011 00:46:26 +0200</pubDate>
        </item>
        <item>
        	<title>tony on small bug fixes in jquery.contextmenu.js plugin</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/small-bug-fixes-in-jquery-contextmenu-js-plugin#p25328</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/small-bug-fixes-in-jquery-contextmenu-js-plugin#p25328</guid>
        	        	<description><![CDATA[<p>Thanks Oleg,</p>
<p>Will check this.</p>
<p>Best Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Mon, 05 Dec 2011 18:23:47 +0200</pubDate>
        </item>
        <item>
        	<title>OlegK on small bug fixes in jquery.contextmenu.js plugin</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/small-bug-fixes-in-jquery-contextmenu-js-plugin#p25321</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/small-bug-fixes-in-jquery-contextmenu-js-plugin#p25321</guid>
        	        	<description><![CDATA[<p>Hello Tony,</p>
<p>I suggest to make small bug fixes in the <em>jquery.contextmenu.js</em> included in jqGrid as plugin.</p>
<p>1) <strong>trigger</strong> variable defined in the <a href="https://github.com/tonytomov/jqGrid/blob/v4.2.0/plugins/jquery.contextmenu.js#L21" target="_blank">line 21</a> will be never used. It can be removed.</p>
<p>2) parameter <strong>options</strong> from the <a href="https://github.com/tonytomov/jqGrid/blob/v4.2.0/plugins/jquery.contextmenu.js#L91" target="_blank">line 91</a>&#160;will be never used in the body of the function <strong>display</strong>. It can be also removed.</p>
<p>3) parameter <strong>e</strong> from the <a href="https://github.com/tonytomov/jqGrid/blob/v4.2.0/plugins/jquery.contextmenu.js#L112" target="_blank">line 112</a> will be also never used and can be removed.</p>
<p>4) The most important bug is that the variable <strong>currentTarget</strong> defined in the <a href="https://github.com/tonytomov/jqGrid/blob/v4.2.0/plugins/jquery.contextmenu.js#L21" target="_blank">line 21</a> will be never assigned and <strong>undefined</strong> value are used in the <a href="https://github.com/tonytomov/jqGrid/blob/v4.2.0/plugins/jquery.contextmenu.js#L114" target="_blank">line 114</a> as the second parameter of <strong>func</strong> function invocation. I suggest to include inside of the oby of <strong>$(this).bind(&#39;contextmenu&#39;, function(e) {</strong>&#160;(for example after the <a href="https://github.com/tonytomov/jqGrid/blob/v4.2.0/plugins/jquery.contextmenu.js#L84" target="_blank">line 84</a>) the assignment</p>
<p><input type='button' class='sfcodeselect' name='sfselectit4414' value='Select Code' data-codeid='sfcode4414' /></p>
<div class='sfcode' id='sfcode4414'>currentTarget = e.target;</div>
<p>You can download the modified version of the <em>jquery.contextmenu.js</em>&#160;file <a href="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-4.2.0/plugins/jquery.contextmenu-fixed.js" target="_blank">here</a>.</p>
<p>After the fix one will have inside of any functions inside of bindings the parameter <strong>currentTarget</strong>&#160;assigned to the DOM element at which the context menu was opened. So instead of binding <strong>contextMenu</strong>&#160;to every row of the grid (call of <strong>$("tr.jqgrow", this).contextMenu(&#39;myMenu1&#39;, {&#8230;})</strong> inside of <strong>loadComplete</strong> every time when grid contain will be rebuild) one will be able to call <strong>$(&#39;#list&#39;).contextMenu(&#39;myMenu1&#39;, {&#8230;})</strong> only <em><span style="text-decoration: underline;">once</span></em>. So the code coule be about the following:</p>
<p><input type='button' class='sfcodeselect' name='sfselectit9125' value='Select Code' data-codeid='sfcode9125' /></p>
<div class='sfcode' id='sfcode9125'>var grid = $(&#39;#list&#39;);<br />grid.contextMenu(&#39;myMenu1&#39;, {<br />&#160; &#160; bindings: {<br />&#160; &#160; &#160; &#160; edit: function (trigger, currentTarget) {<br />&#160; &#160; &#160; &#160; &#160; &#160; var rowId = $(currentTarget).closest(&#34;tr.jqgrow&#34;).attr(&#34;id&#34;);<br />&#160; &#160; &#160; &#160; &#160; &#160; grid.jqGrid(&#39;editGridRow&#39;, rowId, editSettings);<br />&#160; &#160; &#160; &#160; },<br />&#160; &#160; &#160; &#160; add: function () {<br />&#160; &#160; &#160; &#160; &#160; &#160; grid.jqGrid(&#39;editGridRow&#39;, &#34;new&#34;, addSettings);<br />&#160; &#160; &#160; &#160; },<br />&#160; &#160; &#160; &#160; del: function (trigger, currentTarget) {<br />&#160; &#160; &#160; &#160; &#160; &#160; var rowId = $(currentTarget).closest(&#34;tr.jqgrow&#34;).attr(&#34;id&#34;);<br />&#160; &#160; &#160; &#160; &#160; &#160; grid.jqGrid(&#39;delGridRow&#39;, rowId, delSettings);<br />&#160; &#160; &#160; &#160; }<br />&#160; &#160; },<br />&#160; &#160; onContextMenu: function (e) {<br />&#160; &#160; &#160; &#160; var rowId = $(e.target).closest(&#34;tr.jqgrow&#34;).attr(&#34;id&#34;);<br />&#160; &#160; &#160; &#160; if (!rowId) {<br />&#160; &#160; &#160; &#160; &#160; &#160; return false; // no contex menu on rows having no &#34;jqgrow&#34; class<br />&#160; &#160; &#160; &#160; }<br />&#160; &#160; &#160; &#160; grid.jqGrid(&#39;setSelection&#39;, rowId);<br />&#160; &#160; &#160; &#160; return true;<br />&#160; &#160; }<br />});&#160;</div>
<p>where <strong>editSettings</strong>, <strong>addSettings</strong> and <strong>delSettings</strong> can be dfined above. See <a href="http://www.ok-soft-gmbh.com/jqGrid/LocalFormEditingWithContextmenu3.htm" target="_blank">the demo</a>.</p>
<p>Best regards<br />Oleg</p></p>
]]></description>
        	        	<pubDate>Sun, 04 Dec 2011 17:47:42 +0200</pubDate>
        </item>
</channel>
</rss>