根据网格中的列数调整jqGrid的大小 [英] Resize jqGrid according to number of columns in the grid
问题描述
我有jqGrid(免费jqGrid),其中包含7列.然后,我应用了shrinkToFit: false
属性来启用网格列的滚动(以适合移动设备).当我将相同的属性应用于只有一列网格的网格时,如下图所示:
如何根据列数自动设置网格宽度?
您可以使用 上面的代码首先根据外部容器的宽度调整网格的宽度,然后根据主网格表的宽度与网格总宽度之间的差来调整最后一列的宽度. /p> I have jqGrid (free jqGrid) that contains 7 columns. And I applied How to automatically set grid width according to the number of columns? You can use The above code first resize the width of grid based on the width of the outer container and then adjust the width of the last column based on the difference between the width of the main grid table and the total width of the grid. 这篇关于根据网格中的列数调整jqGrid的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!setColWidth
方法(包含在演示的修改如下:shrinkToFit: false
, property to enable scrolling for the grid columns (to fit to mobile device). When I applied the same property to the grid having only one column grid is looking like below image :setColWidth
method (included in free jqGrid) to change the width of the last column dynamically. I don't know which scenario for loading the grid you use. The modification of the demo could be the following: http://jsfiddle.net/OlegKi/andm1299/37/ where$(window).bind("resize", function () {
var p = $grid.jqGrid("getGridParam"),
cm = p.colModel[p.iColByName.ComboDuration];
$grid.jqGrid("setGridWidth", $grid.closest(".container-fluid").width());
$grid.jqGrid("setColWidth", "ComboDuration", p.width - p.tblwidth + cm.width);
}).triggerHandler("resize");