开发者

In jqGrid, is it possible to resize columns to fit the table width (original width) after hide a column?

开发者 https://www.devze.com 2023-04-12 09:18 出处:网络
I am using shrinkToFit = true property to fit the table with columns width(proportional sizing), in the mean time I also want to hide a column but does not want to change the width of the table. If sh

I am using shrinkToFit = true property to fit the table with columns width(proportional sizing), in the mean time I also want to hide a column but does not want to change the width of the table. If shrinkTofit is set true, the table width also shrinks with the amount of the width of the hidden column. Let me give an example,

Configuration:

ShrinkToFit = true
Table width = 800,
Two columns exist: 
ColumnA width=200,
ColumnB width=200

when jqgrid is constructed the widths will be calculated like that:

TableWidth = 800,
Width of ColumnA = 400, 
Width of ColumnB = 400

When ColumnB is set to h开发者_开发问答idden,widths will be (normal behaviour):

table width=400
ColumnA width =400

My Desired Behaviour:

table width = 800
ColumnA width = 800

Is is possible to achieve this behaviour?

thanks in advance, Alper.


If I understand you correct you can just call setGridWidth method one more time with the current grid width and true as the next (shrink) parameter:

var myGrid = $("#list"),
    width = myGrid.jqGrid('getGridParam', 'width'); // get current width
myGrid.jqGrid('setGridWidth', width, true);

This will not change the width of the grid, but force the shrinking of the columns.

0

精彩评论

暂无评论...
验证码 换一张
取 消