如何制作jqGrid流体高度?

如何制作jqGrid流体高度?,jqgrid,height,jqgrid-php,Jqgrid,Height,Jqgrid Php,很长一段时间以来,我一直在寻找如何在jqGrid中生成流体高度的答案,但我仍然没有找到它 所以,我需要流体高度 我知道如何制作流体宽度: jQuery(window).resize(function(){ gridId = "grid"; gridParentWidth = $('#gbox_' + gridId).parent().width(); $('#' + gridId).jqGrid('setGridWidth',gridParentWidth); }) 我试过了 gridPar

很长一段时间以来,我一直在寻找如何在jqGrid中生成流体高度的答案,但我仍然没有找到它

所以,我需要流体高度

我知道如何制作流体宽度:

jQuery(window).resize(function(){
gridId = "grid";

gridParentWidth = $('#gbox_' + gridId).parent().width();
$('#' + gridId).jqGrid('setGridWidth',gridParentWidth);
})
我试过了

gridParentHeight = $('#gbox_' + gridId).parent().height();
$('#' + gridId).jqGrid('setGridHeight',gridParentHeight);
但这是行不通的


有解决办法吗?

我找到了解决问题的办法。以下是代码(适用于Firefox):

winHeight=window.innerHeight;
wHeight=winHeight-90;
$(“#grid”).jqGrid('setGridHeight',wHeight);
jQuery(窗口).resize(函数(){
gridId=“grid”;
gridWidth=$('#gbox'+gridId).parent().width();
$('#'+gridId).jqGrid('setGridWidth',gridWidth);
如果(wHeight<110){//网格中五行的高度为110像素。
wHeight=110;
$('#'+gridId).jqGrid('setGridHeight',wHeight);
}
否则{
$('#'+gridId).jqGrid('setGridHeight',wHeight);
}

我很欣赏这是一个老问题,但这里有一个CSS(因此更平滑)解决方案

beforeRequest: function () {
  setTimeout(function () {
    var gridName = this.id;
    $('#gbox_' + gridName).css({
      position: 'absolute',
      top: 0,
      bottom: $('#gbox_' + gridName + ' .ui-pager-control').outerHeight() + 'px',
      width: '100%',
      height: '100%'
    });
    $('#gbox_' + gridName + ' .ui-jqgrid-view').css({ 'height': '100%' });
    $('#gbox_' + gridName + ' .ui-jqgrid-bdiv').css({
      position: 'absolute',
      top: $('#gbox_' + gridName + ' .ui-jqgrid-titlebar').outerHeight() + $('#gbox_' + gridName + ' .ui-jqgrid-hbox').outerHeight() + 'px',
      bottom: 0,
      left: 0,
      right: 0,
      height: '',
      width: ''
    });
  }, 100);
}

这个动作的例子:

我个人更喜欢使用<代码>高度:'Auto' 。如果你需要让寻呼机始终可见,你可以考虑使用ToppHER(例如,它),这样你就不会有与你所描述的相同的行为,而是另一个拥有相同用户体验的人。
beforeRequest: function () {
  setTimeout(function () {
    var gridName = this.id;
    $('#gbox_' + gridName).css({
      position: 'absolute',
      top: 0,
      bottom: $('#gbox_' + gridName + ' .ui-pager-control').outerHeight() + 'px',
      width: '100%',
      height: '100%'
    });
    $('#gbox_' + gridName + ' .ui-jqgrid-view').css({ 'height': '100%' });
    $('#gbox_' + gridName + ' .ui-jqgrid-bdiv').css({
      position: 'absolute',
      top: $('#gbox_' + gridName + ' .ui-jqgrid-titlebar').outerHeight() + $('#gbox_' + gridName + ' .ui-jqgrid-hbox').outerHeight() + 'px',
      bottom: 0,
      left: 0,
      right: 0,
      height: '',
      width: ''
    });
  }, 100);
}