【问题标题】:How to make jqGrid fluid height?如何使jqGrid流体高度?
【发布时间】:2011-10-11 07:16:40
【问题描述】:

一直在找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);

但这不起作用。

有解决办法吗?

【问题讨论】:

  • 我个人更喜欢使用height:'auto'。如果您需要让寻呼机始终可见,您可以考虑使用 toppager(例如,参见 here)。它的方式与您描述的行为不同,但另一种行为具有相同的用户体验。

标签: jqgrid height jqgrid-php


【解决方案1】:

我找到了解决问题的方法。这是代码(在 Firefox 中工作):

winHeight = window.innerHeight;
wHeight = winHeight - 90;

$("#grid").jqGrid('setGridHeight',wHeight);

jQuery(window).resize(function(){
    gridId = "grid";
    gridWidth = $('#gbox_' + gridId).parent().width();

    $('#' + gridId).jqGrid('setGridWidth',gridWidth);
    if(wHeight < 110){  //Height of five rows in grid is 110 pixels.
        wHeight = 110;
        $('#'+ gridId).jqGrid('setGridHeight',wHeight);
    }
    else {
        $('#'+ gridId).jqGrid('setGridHeight',wHeight);
}

【讨论】:

    【解决方案2】:

    我很欣赏这是一个旧线程 - 但这是一个 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);
    }
    

    一个例子:http://jsfiddle.net/Ba5yK/16/

    【讨论】:

      猜你喜欢
      • 2013-03-25
      • 2011-10-26
      • 2011-11-25
      • 2014-10-28
      • 1970-01-01
      • 2013-06-17
      • 2015-03-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多