Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
shrinkToFit is always happening for me
08/08/2008
06:09
Avatar
max-williams
Member
Members
Forum Posts: 8
Member Since:
01/08/2008
sp_UserOfflineSmall Offline

Probably the same bug as here -

http://www.trirand.com/blog/?p.....post-1084/

But the circumstances are slightly different.

I have a width explicitly set for every column in my colModel, and i have no table width or shrinkToFit set, and that's fine - the table autosizes  to the combined width of the columns in colModel.  

However, i want the table to be a bit bigger than the combined width, so i set the 'width' option to be larger than the total width, and set shrinkToFit: false.  And then, it seems like shrinkToFit kicks in and my column widths break (it's really obvious that they break because i've filled each cell with textfields, and they don't match the new widths).  I tried setting the default value for shrinkToFit to false in the the source and it's the same.

In other words, if width is set, it always changes the widths of the individual columns, whether shrinkToFit is set or not.   This is using version 3.2

Thanks!

max

08/08/2008
06:46
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

I think you should use 3.2.1.

And shrink to fit is used in oposite way - smal table width

many columns

Also do you have hidden columns?

Note that when shrink to fit is used the width of the hidden

columns is not included in the recalculation

Regards

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

08/08/2008
06:58
Avatar
max-williams
Member
Members
Forum Posts: 8
Member Since:
01/08/2008
sp_UserOfflineSmall Offline

I was thinking about this some more, and in a way it doesn't make sense to have the table bigger than the sum of the column widths.  But, i still don't want to stretch all of them.  So, i came up with an alternative solution - if we have 'width' specified, and shrinkToFit = false, then we can resize ONLY THE LAST column to fit the table. 

This works better for me, but it might not be to everyone's needs so i'm posting it here for your opinion. 
[code]

#grid.base.js - original version

#line 905 - 910
for(l=0;l<ts.p.colModel.length;l++) {
  if(!ts.p.shrinkToFit){
    ts.p.colModel[l].owidth = ts.p.colModel[l].width;
  }
  ts.p.colModel[l].width = Math.round(tblwidth/initwidth*ts.p.colModel[l].width);
}

#my modified version
if(ts.p.shrinkToFit){
  //resize all columns to fit the table
  for(l=0;l<ts.p.colModel.length;l++) {      
    ts.p.colModel[l].owidth = ts.p.colModel[l].width;
    ts.p.colModel[l].width = Math.round(tblwidth/initwidth*ts.p.colModel[l].width);
  }         
} else {
  //make only the last column wider to fit the table
  ts.p.colModel[ts.p.colModel.length - 1].width += (tblwidth - initwidth);
}

[/code]

Thanks - max

08/08/2008
07:52
Avatar
max-williams
Member
Members
Forum Posts: 8
Member Since:
01/08/2008
sp_UserOfflineSmall Offline

“tony said:

I think you should use 3.2.1.”

Sorry tony, i thought i posted a correction saying it was 3.2.1, not 3.2.  But i clearly didn't.

“And shrink to fit is used in oposite way - smal table width

many columns

Also do you have hidden columns?

Note that when shrink to fit is used the width of the hidden

columns is not included in the recalculation”

yeah -  i do have hidden columns.  Basically my problem was that the columns were being resized even though shrinkToFit isn't used - but in my case, like you say, the starting situation is that the total column width is less than the table width, so maybe shrinkToFit isn't relevant.  It's a bit confusing though, to me at least.  Maybe a new option, 'expandToFit' is needed?  :)


17/10/2008
17:15
Avatar
davidelewis
Member
Members
Forum Posts: 20
Member Since:
16/07/2008
sp_UserOfflineSmall Offline

Either this problem or a related problem seems to be introduced in the 3.3 release ...

With jqGrid 3.2.x, if I have a grid with 4 columns, each 150 pixels wide - and  the grid width is 600 pixels - when a column is hidden and the "shrinkToFit" is set to false, the grid width automatically reduces in size. With the 3.3 release, the grid does not resize smaller.

I think that an "expandToFit" would be a great feature ... also the ability to set column with to "auto", so that the width is based on the maximum text width within a column - like a convensional HTML table.

Ideas?

19/10/2008
07:41
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

$(..).jqGrid({}).setGridWidth(600,false)

Regards

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

21/10/2008
16:08
Avatar
davidelewis
Member
Members
Forum Posts: 20
Member Since:
16/07/2008
sp_UserOfflineSmall Offline

Your suggestion resizes the grid, but not the grid header (<div/> with the class="GridHeader"). From my example above, after hiding one of the four columns - the three remaing columns take up approx 450 pixels while the header remains 600 pixels. As soon as I resize a column, the header "snaps" to the correct width. I'm guessing that the width of the hidden column (zero pixels) is not being included in the calculation of the grid header width.

Any other solutions?

21/10/2008
16:11
Avatar
davidelewis
Member
Members
Forum Posts: 20
Member Since:
16/07/2008
sp_UserOfflineSmall Offline

Whoops! Embarassed

I doubled checked this again ... If I set the grid width after hiding the column, then your solution works

$("#grid").jqGrid({}).setGridWidth(600, false);

Thanks!

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
37 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information