我有一个jQueryUI对话框(#locDialog
)里面有一个jqGrid($grid
).当对话框打开时(最初,但只要它打开就会被调用),我想要$grid
调整大小$locDialog
.当我最初这样做时,我在网格内部(不在对话框内)获得滚动条.
如果我调试代码,我看到的宽度$grid
是677.所以,我setGridWidth()
再次调用并检查宽度,现在我有659,这是18px少,这是jqGrid(Dun-dun)的滚动区域的大小-逼债..)
当我重新对话时,我也调整了网格的大小,一切都很快乐 - 没有滚动条,除非必要.
我的对话框初始代码:
$locDialog = $('#location-dialog').dialog({
autoOpen: false,
modal: true,
position: ['center', 100],
width: 700,
height:500,
resizable: true,
buttons: {
"Show Selected": function() {alert($('#grid').jqGrid('getGridParam','selarrrow'));},
"OK": function() {$(this).dialog('close');},
"Cancel": function() {$(this).dialog('close');}
},
open: function(event, ui) {
$grid.setGridHeight($(this).height()-54);
// No idea why 54 is the magic number here
$grid.setGridWidth($(this).width(), true);
},
close: function(event, ui) {
},
resizeStop: function(event, ui) {
$grid.setGridWidth($locDialog.width(), true);
$grid.setGridHeight($locDialog.height()-54);
}
});
Run Code Online (Sandbox Code Playgroud)
我很好奇,如果有人见过这个.真的,如果我最初有不必要的滚动条,它不是世界末日,但是当我最初调用setGridWidth时,它并没有考虑到18px的滚动区域.
至于神奇的数字54,这是我必须从对话框值的高度中减去的数字,以使网格呈现而没有不必要的滚动条. …