<?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: setGridWidth method causes column resize even if shrinkToFit = false</title>
	<link>http://www.trirand.com/blog/?page_id=393/bugs/setgridwidth-method-causes-column-resize-even-if-shrinktofit-false</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/setgridwidth-method-causes-column-resize-even-if-shrinktofit-false/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>tony on setGridWidth method causes column resize even if shrinkToFit = false</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/setgridwidth-method-causes-column-resize-even-if-shrinktofit-false#p7036</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/setgridwidth-method-causes-column-resize-even-if-shrinktofit-false#p7036</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>Thanks again. Need to be tested, but I think moving to 3.5 is better.</p>
<p>Best Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Thu, 04 Jun 2009 03:20:30 +0300</pubDate>
        </item>
        <item>
        	<title>phazzy on setGridWidth method causes column resize even if shrinkToFit = false</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/setgridwidth-method-causes-column-resize-even-if-shrinktofit-false#p7028</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/setgridwidth-method-causes-column-resize-even-if-shrinktofit-false#p7028</guid>
        	        	<description><![CDATA[<p>Hi, I put this matter aside for some time, waiting for some fix. Well, it has not come out yet and I needed the feature. So, I digged in the code and debugged it to try to find the problem.</p>
<p>The problem seems to be in the setGridWidth function. I think the code that has &#8220;the problem&#8221; is:</p>
<p>[code]</p>
<p>cw = shrink !== true ? $(&#8221;tr:first th:eq(&#8221;+i+&#8221;)&#8221;,$t.grid.hDiv).css(&#8221;width&#8221;) : this.width;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; w = Math.floor((IENum(nwidth)-IENum(testdata[2]))/IENum(testdata[0])*IENum(cw));<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; chw += w;</p>
<p>[/code]</p>
<p>The variable cw seems to be some kind of additional value used when computing the width of the resized column, and if shrik parameter is false, it takes the value from the declared column&#160; width.</p>
<p>The problem is the line</p>
<p>[code] w = Math.floor((IENum(nwidth)-IENum(testdata[2]))/IENum(testdata[0])*IENum(cw)); [/code]</p>
<p>, that computes w to be the resized column&#160; width, using the above cw as &#8220;parameter&#8221; value. Even if the testdata[2]&#160; variable is set to be 0 when shrink is false, the value w that later is used to set the column width gets an altered value from the original.</p>
<p>So I modified the above code to be :</p>
<p>[code]</p>
<p>cw = shrink !== true ? $(&#8221;tr:first th:eq(&#8221;+i+&#8221;)&#8221;,$t.grid.hDiv).css(&#8221;width&#8221;) : this.width;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; w = 0;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; if(shrink == true)<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; &#160;&#160;&#160;&#160;&#160;&#160;&#160; w = Math.floor((IENum(nwidth)-IENum(testdata[2]))/IENum(testdata[0])*IENum(cw));<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; &#160;&#160;&#160; else<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; &#160;&#160;&#160;&#160;&#160;&#160;&#160; w = IENum(cw);<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; }</p>
<p>[/code]</p>
<p>This way w always gets the original column width, and the column width is not altered.</p>
<p>I think the testdata variable has something to do with the above calculations, but I didn&#39;t looked further into this problem. The above modifications solved my issue. The &#8220;bad&#8221; part is that if you want to modify you have to used the unpacked .js files, or modify it and then repack it again (I don&#39;t know how to do that).</p>
<p>I don&#39;t claim that the modification that I made solves the issue of shrinkToFit, it is just a minor adjustment that I made so the column width remains the same.</p></p>
]]></description>
        	        	<pubDate>Wed, 03 Jun 2009 05:18:54 +0300</pubDate>
        </item>
        <item>
        	<title>sweetp on setGridWidth method causes column resize even if shrinkToFit = false</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/setgridwidth-method-causes-column-resize-even-if-shrinktofit-false#p6413</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/setgridwidth-method-causes-column-resize-even-if-shrinktofit-false#p6413</guid>
        	        	<description><![CDATA[<p>Any update on this? Did it get rolled into a new release?</p>
]]></description>
        	        	<pubDate>Thu, 30 Apr 2009 17:31:47 +0300</pubDate>
        </item>
        <item>
        	<title>phazzy on setGridWidth method causes column resize even if shrinkToFit = false</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/setgridwidth-method-causes-column-resize-even-if-shrinktofit-false#p5855</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/setgridwidth-method-causes-column-resize-even-if-shrinktofit-false#p5855</guid>
        	        	<description><![CDATA[<blockquote>
<p>tony said:</p>
<p>Hello,</p>
<p>Thanks. If I look into the code right now - there is a really problem with this.</p>
<p>Let me to try to correct this.</p>
</p>
<p>Regards</p>
<p>Tony</p>
</blockquote>
<hr />
<p>Hi , did you managed to resolve the issue or find a workaround ? I was needing this feature for a work project.</p>
<p>Best regards,</p>
<p>phazzy</p>
]]></description>
        	        	<pubDate>Mon, 06 Apr 2009 01:52:23 +0300</pubDate>
        </item>
        <item>
        	<title>racingcow on setGridWidth method causes column resize even if shrinkToFit = false</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/setgridwidth-method-causes-column-resize-even-if-shrinktofit-false#p5456</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/setgridwidth-method-causes-column-resize-even-if-shrinktofit-false#p5456</guid>
        	        	<description><![CDATA[<p>Thanks for looking into it for us, Tony. You are awesome!</p>
]]></description>
        	        	<pubDate>Thu, 19 Mar 2009 15:20:10 +0200</pubDate>
        </item>
        <item>
        	<title>tony on setGridWidth method causes column resize even if shrinkToFit = false</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/setgridwidth-method-causes-column-resize-even-if-shrinktofit-false#p5386</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/setgridwidth-method-causes-column-resize-even-if-shrinktofit-false#p5386</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>Thanks. If I look into the code right now - there is a really problem with this.</p>
<p>Let me to try to correct this.</p>
</p>
<p>Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Tue, 17 Mar 2009 01:40:10 +0200</pubDate>
        </item>
        <item>
        	<title>racingcow on setGridWidth method causes column resize even if shrinkToFit = false</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/setgridwidth-method-causes-column-resize-even-if-shrinktofit-false#p5377</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/setgridwidth-method-causes-column-resize-even-if-shrinktofit-false#p5377</guid>
        	        	<description><![CDATA[<blockquote>
<p>tony said:</p>
<p>Hello,</p>
<p>Also use the second parameter in setGridWidth - see Docs.</p>
<p>Regards</p>
<p>Tony</p>
</blockquote>
<hr />
<p>Tony,</p>
<p>According to the docs, the second parameter "<em>has the same behavior as shrinkToFit</em>". The description of "shrinkToFit" in the docs says, "<em>If the value is false and the value in width option is set then: The width of the grid is the width set in option. The column width are not recalculated and have the values defined in colModel.</em>"</p>
<p>This "shrinkToFit = false" behavior is what I am trying to get. I don&#39;t want the columns to resize whenever I call setGridWidth.</p>
<p>If you look at my code, I am setting the second parameter to "false" on this line...</p>
<p><span class="sfcode">$(&#8221;#gridContainer&#8221;).setGridWidth(200, false);</span></p>
<p>I have tried setting the parameter to "true", but that doesn&#39;t do what I want either.</p>
<p>Any help you could give me would be greatly appreciated.</p>
<p>-David</p>
]]></description>
        	        	<pubDate>Mon, 16 Mar 2009 11:09:36 +0200</pubDate>
        </item>
        <item>
        	<title>phazzy on setGridWidth method causes column resize even if shrinkToFit = false</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/setgridwidth-method-causes-column-resize-even-if-shrinktofit-false#p5376</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/setgridwidth-method-causes-column-resize-even-if-shrinktofit-false#p5376</guid>
        	        	<description><![CDATA[<p>Hello.</p>
<p>I also have this problem of resizing. I set "shrinkToFit" to false and I called setGridWidth with second parameter = "false". All the columns in colModel have the "width" parameter set. After the resizing of the grid, all the columns are resized too, acording to the new grid size.</p>
<p>The thing that I want to do is to resize the grid and don&#39;t resize the columns, so that the horizontal scrollbar appears, and user may scroll and view the full contents of the cells.</p>
<p>Your help will be greatly appreciated.</p>
<p>Best regards</p>
]]></description>
        	        	<pubDate>Mon, 16 Mar 2009 07:51:50 +0200</pubDate>
        </item>
        <item>
        	<title>tony on setGridWidth method causes column resize even if shrinkToFit = false</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/setgridwidth-method-causes-column-resize-even-if-shrinktofit-false#p5210</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/setgridwidth-method-causes-column-resize-even-if-shrinktofit-false#p5210</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>Also use the second parameter in setGridWidth - see Docs.</p>
<p>Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Wed, 11 Mar 2009 01:55:39 +0200</pubDate>
        </item>
        <item>
        	<title>racingcow on setGridWidth method causes column resize even if shrinkToFit = false</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/setgridwidth-method-causes-column-resize-even-if-shrinktofit-false#p5190</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/setgridwidth-method-causes-column-resize-even-if-shrinktofit-false#p5190</guid>
        	        	<description><![CDATA[<p>Anyone else having this problem?</p>
]]></description>
        	        	<pubDate>Mon, 09 Mar 2009 10:27:56 +0200</pubDate>
        </item>
        <item>
        	<title>racingcow on setGridWidth method causes column resize even if shrinkToFit = false</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/setgridwidth-method-causes-column-resize-even-if-shrinktofit-false#p4913</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/setgridwidth-method-causes-column-resize-even-if-shrinktofit-false#p4913</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>I am trying to dynamically resize a grid using the "setGridWidth" method. When I call "setGridWidth" on a grid to make the size of the grid smaller, it appears to resize the columns in the grid to fit the new grid width, even if I have "shrinkToFit" set to false. After reading the documentation on shrinkToFit, I expected the column widths to not be changed after the grid was resized.</p>
<p>I really want the column widths to stay their original sizes after setGridWidth is called. Is this a bug, is there some workaround, or am I just not understanding how shrinkToFit works?</p>
<p>Here is an example that reproduces the issue. Clicking the "Click Me" button will resize the grid to a smaller size, causing the columns to resize...</p>
<p><input type='button' class='sfcodeselect' name='sfselectit8976' value='Select Code' data-codeid='sfcode8976' /></p>
<div class='sfcode' id='sfcode8976'>
<p>&#60;html xmlns="<a href="http://www.w3.org/1999/xhtml" target="_blank">http://www.w3.org/1999/xhtml</a>"&#62;<br />&#60;head&#62;<br />&#60;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /&#62;</p>
<p>&#60;script src="jquery.js" type="text/javascript"&#62;&#60;/script&#62;<br />&#60;script src="custom.js" type="text/javascript"&#62;&#60;/script&#62;<br />&#60;script src="jquery.jqGrid.js" type="text/javascript"&#62;&#60;/script&#62;</p>
<p>&#60;script type="text/javascript"&#62;<br />&#160;$(document).ready(function() {<br />&#160;&#160;<br />&#160;&#160;var mystr = "&#60;?xml version=&#39;1.0&#39; encoding=&#39;utf-8&#39;?&#62;&#60;invoices&#62;&#60;rows&#62;&#60;row&#62;&#60;cell&#62;data1&#60;/cell&#62;&#60;cell&#62;data2&#60;/cell&#62;&#60;cell&#62;data3&#60;/cell&#62;&#60;/row&#62;&#60;row&#62;&#60;cell&#62;data1&#60;/cell&#62;&#60;cell&#62;data2&#60;/cell&#62;&#60;cell&#62;data3&#60;/cell&#62;&#60;/row&#62;&#60;/rows&#62;&#60;/invoices&#62;";</p>
<p>&#160;&#160;$("#clickMe").click(function() {<br />&#160;&#160;&#160;$("#gridContainer").setGridWidth(200, false);<br />&#160;&#160;});</p>
<p>&#160;&#160;$("#gridContainer").jqGrid({<br />&#160;&#160;&#160;datatype: &#39;xmlstring&#39;,<br />&#160;&#160;&#160;colNames: [&#39;Id&#39;, &#39;Name&#39;, &#39;Description&#39;],<br />&#160;&#160;&#160;colModel: [<br />&#160;&#160;&#160;&#160;&#160;{ name: &#39;id&#39;, index: &#39;id&#39;, width: 150, resizable: true },<br />&#160;&#160;&#160;&#160;&#160;{ name: &#39;name&#39;, index: &#39;name&#39;, width: 200, resizable: true, sorttype: &#39;text&#39; },<br />&#160;&#160;&#160;&#160;&#160;{ name: &#39;description&#39;, index: &#39;description&#39;, width: 250, resizable: true}],<br />&#160;&#160;&#160;datastr: mystr,<br />&#160;&#160;&#160;width: 400,<br />&#160;&#160;&#160;shrinkToFit: false,<br />&#160;&#160;&#160;imgpath: &#39;themes/steel/images&#39;,<br />&#160;&#160;});<br />&#160;});<br />&#60;/script&#62;</p>
<p>&#60;/head&#62;<br />&#60;body&#62;<br />&#160;&#60;p&#62;Here is some text&#60;/p&#62;<br />&#160;&#60;table id="gridContainer" class="scroll" cellpadding="0" cellspacing="0" /&#62;<br />&#160;&#60;input id="clickMe" type="button" value="Click Me" /&#62;<br />&#60;/body&#62;<br />&#60;/html&#62;</p>
</div>
<p>Thanks for your help.</p>
<p>-Dave</p>
]]></description>
        	        	<pubDate>Tue, 24 Feb 2009 15:57:57 +0200</pubDate>
        </item>
</channel>
</rss>