<?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: two BUGs on setLabel method of 4.2.0</title>
	<link>http://www.trirand.com/blog/?page_id=393/feature-request/two-bugs-on-setlabel-method-of-4-2-0</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/feature-request/two-bugs-on-setlabel-method-of-4-2-0/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>redoak2000 on two BUGs on setLabel method of 4.2.0</title>
        	<link>http://www.trirand.com/blog/?page_id=393/feature-request/two-bugs-on-setlabel-method-of-4-2-0#p25282</link>
        	<category>Feature Request</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/feature-request/two-bugs-on-setlabel-method-of-4-2-0#p25282</guid>
        	        	<description><![CDATA[<p>First of all, I&#39;m a newbie in js &#38; jqgrid.</p>
<p>I&#39;m using jqGrid&#160; 4.2.0. I love jqgrid.&#160; I wish this can be fixed in the next version.</p>
</p>
<p>Yestoday, I want to use setLabel to change the column names of some column.&#160; I found two BUGs.</p>
<p>1. setLabel ONLY works with column names. But in the wiki, it said works with both names and ID.</p>
<p>2. when groupHeaders feature is used, eg. use setGroupHeaders to setup some group headers.&#160; setLabel works very strange.</p>
<p>&#160;&#160; after about 4 hours try and try, the BUG is found.&#160; I&#39;m not sure on my modifications, so , I just add a new method named by setLabelByID. original function is leaved not changed. In my project, I use setLabelByID only.</p>
<p>&#160;&#160;&#160; setLabel : function(colname, nData, prop, attrp ){<br />&#160;&#160; &#160;&#160;&#160; &#160;return this.each(function(){<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;var $t = this, pos=-1;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;if(!$t.grid) {return;}<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;if(typeof(colname) != "undefined") {<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;$($t.p.colModel).each(function(i){<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;if (this.name == colname) {<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;pos = i;return false;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;}<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;});<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;} else { return; }<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;if(pos&#62;=0) {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color: #ff0000;"><strong> // th:eq pos error when groupHeaders exists.</strong></span><br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160;&#160; <span style="color: #ff0000;">var thecol = $("tr.ui-jqgrid-labels th:eq("+pos+")",$t.grid.hDiv);</span> <strong><span style="color: #ff0000;">//maybe this selector is wrong when groupHeaders is used</span></strong><br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;if (nData){<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;var ico = $(".s-ico",thecol);<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;<span style="color: #ff0000;">$("[id^=jqgh_]",thecol).empty().html(nData).append(ico);</span><span style="color: #ff0000;"><strong>//maybe this line is wrong. I&#39;m not sure.</strong></span><br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;$t.p.colNames[pos] = nData;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;}<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;if (prop) {<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;if(typeof prop === &#39;string&#39;) {$(thecol).addClass(prop);} else {$(thecol).css(prop);}<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;}<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;if(typeof attrp === &#39;object&#39;) {$(thecol).attr(attrp);}<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;}<br />&#160;&#160; &#160;&#160;&#160; &#160;});<br />&#160;&#160; &#160;},<br />&#160;&#160;&#160; <strong><span style="color: #ff0000;">setLabelByID</span></strong>: function (pos, nData) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; return this.each(function () {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var $t = this;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (!$t.grid) { return; }</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (pos &#62;= 0 ) {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color: #ff0000;"><strong> //this works well.</strong></span><br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <strong><span style="color: #ff0000;">var thecol = $("#jqgh_"+ $t.id + &#39;_&#39;+$t.p.colModel[pos].name, $t.grid.hDiv);</span></strong><br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (nData) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var ico = $(".s-ico", thecol);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; thecol.empty().html(nData).append(ico);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $t.p.colNames[pos] = nData;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; });<br />&#160;&#160;&#160; },</p>
<p>Best regards.</p>
]]></description>
        	        	<pubDate>Thu, 01 Dec 2011 02:26:33 +0200</pubDate>
        </item>
</channel>
</rss>