Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

jquery

jqgrid

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 hidden,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.

like image 539
Alper Turkyilmaz Avatar asked Feb 23 '23 17:02

Alper Turkyilmaz


1 Answers

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.

like image 185
Oleg Avatar answered Apr 30 '23 21:04

Oleg