在jqGrid中,隐藏列后是否可以调整列的大小以适合表的宽度(原始宽度)? [英] In jqGrid, is it possible to resize columns to fit the table width (original width) after hide a column?

查看:351
本文介绍了在jqGrid中,隐藏列后是否可以调整列的大小以适合表的宽度(原始宽度)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用rinkleToFit = true属性来使表与列的宽度(比例大小)匹配,与此同时,我也想隐藏一列,但不想更改表的宽度.如果将rinkleTofit设置为true,则表的宽度也会随着隐藏列的宽度而缩小.让我举一个例子,

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,

配置:

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

在构造jqgrid时,宽度的计算如下:

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

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

将ColumnB设置为隐藏时,宽度将是(正常行为):

table width=400
ColumnA width =400

我想要的行为:

My Desired Behaviour:

table width = 800
ColumnA width = 800

可以实现这种行为吗?

先谢谢了, 阿尔珀.

推荐答案

如果我理解您的观点正确,您可以再调用一次setGridWidth方法,将当前网格widthtrue作为下一个()参数:

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.

这篇关于在jqGrid中,隐藏列后是否可以调整列的大小以适合表的宽度(原始宽度)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆