Forum
06:09
01/08/2008
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
06:46
Moderators
30/10/2007
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.
06:58
01/08/2008
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
07:52
01/08/2008
“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:15
16/07/2008
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?
07:41
Moderators
30/10/2007
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.
16:08
16/07/2008
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?
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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66