<?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: fixing width of grid in showHideCol in case of shrinkToFit===true</title>
	<link>http://www.trirand.com/blog/?page_id=393/bugs/fixing-width-of-grid-in-showhidecol-in-case-of-shrinktofittrue</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/fixing-width-of-grid-in-showhidecol-in-case-of-shrinktofittrue/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>OlegK on fixing width of grid in showHideCol in case of shrinkToFit===true</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/fixing-width-of-grid-in-showhidecol-in-case-of-shrinktofittrue#p26636</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/fixing-width-of-grid-in-showhidecol-in-case-of-shrinktofittrue#p26636</guid>
        	        	<description><![CDATA[<p>Hello Tony,</p>
<p>I described the problem with the fix ealy in <a href="http://stackoverflow.com/a/9599685/315935" target="_blank">the answer</a>, but forgot to post it in the forum.</p>
<p>The problem is easy. The current code of <strong>showHideCol</strong> increase or decrease correctly the grid width only in case of <strong>shrinkToFit</strong>===false. In the code will be corrected adjusted the value of <strong>$t.p.tblwidth</strong> in <a href="https://github.com/tonytomov/jqGrid/blob/v4.3.2/js/grid.base.js#L3042" target="_blank">the line</a>, but the value will be just ignored in <a href="https://github.com/tonytomov/jqGrid/blob/v4.3.2/js/grid.base.js#L3049" target="_blank">the following line</a>.</p>
<p>To fix the problem I suggest modify <a href="https://github.com/tonytomov/jqGrid/blob/v4.3.2/js/grid.base.js#L3041" target="_blank">the line</a></p>
<p><input type='button' class='sfcodeselect' name='sfselectit7056' value='Select Code' data-codeid='sfcode7056' /></p>
<div class='sfcode' id='sfcode7056'>cw = this.widthOrg? this.widthOrg: parseInt(this.width,10);</div>
<p>to the following</p>
<p><input type='button' class='sfcodeselect' name='sfselectit7298' value='Select Code' data-codeid='sfcode7298' /></p>
<div class='sfcode' id='sfcode7298'>cw&#160;=&#160;this.widthOrg&#160;<strong>&#38;&#38;&#160;$t.p.shrinkToFi</strong><strong>t</strong>&#160;?&#160;this.widthOrg:&#160;parseInt(this.width,10);</div>
<p>and modify <a href="https://github.com/tonytomov/jqGrid/blob/v4.3.2/js/grid.base.js#L3049" target="_blank">another line</a></p>
<p><input type='button' class='sfcodeselect' name='sfselectit7257' value='Select Code' data-codeid='sfcode7257' /></p>
<div class='sfcode' id='sfcode7257'>$($t).jqGrid(&#34;setGridWidth&#34;,$t.p.shrinkToFit === true ? $t.p.tblwidth : $t.p.width );</div>
<p>to</p>
<p><input type='button' class='sfcodeselect' name='sfselectit3605' value='Select Code' data-codeid='sfcode3605' /></p>
<div class='sfcode' id='sfcode3605'>$($t).jqGrid(&#34;setGridWidth&#34;,&#160;$t.p.tblwidth);</div>
<p>It&#39;s all the bug ifself. Another issue described in <a href="http://stackoverflow.com/a/9599685/315935" target="_blank">the answer</a> is more the changing of behavior on the column resizing.</p>
<p>The <strong>resizeStop</strong> described in <a href="http://stackoverflow.com/a/9599685/315935" target="_blank">the answer</a></p>
<p><input type='button' class='sfcodeselect' name='sfselectit2532' value='Select Code' data-codeid='sfcode2532' /></p>
<div class='sfcode' id='sfcode2532'><strong>resizeStop: function () {<br />&#160; &#160; var $grid = $(this.bDiv).find(&#39;&#62;:first-child&#62;.ui-jqgrid-btable:last-child&#39;),<br />&#160; &#160; &#160; &#160; shrinkToFit = $grid.jqGrid(&#39;getGridParam&#39;, &#39;shrinkToFit&#39;);<br />&#160; &#160; $grid.jqGrid(&#39;setGridWidth&#39;, this.newWidth, shrinkToFit);<br />}</strong></div>
<p>I use personally always since I wrote the answer. I like the behavior because I don&#39;t specify <strong>width</strong> parameter of the grid and want to hold the width of grid as the sum of the width of all columns. So it&#39;s logical to increase or decrease the width of the grid after resizing of the column. As the result one have grid which never have any horizontal scroll bar.</p>
<p>To make common solution from the above code one can just save the original value of the <strong>width</strong> parameter of the grid in for example <strong>orgWidth</strong> parameter. In the case one can test it inside of <strong>dragEnd</strong> (somewhere before calling of <strong>resizeStop</strong>) and do the same as above in case if <strong>orgWidth</strong>&#160;parameter converted to int is NaN.</p>
<p>Best regards<br />Oleg&#160;</p>
]]></description>
        	        	<pubDate>Sat, 19 May 2012 00:26:44 +0300</pubDate>
        </item>
</channel>
</rss>