Setting Kendo UI grid height 100% of wrapper

后端 未结 4 1108
无人共我
无人共我 2020-12-13 21:45

I know there is an easy way to set fixed height of a Kendo UI grid through their API but for our specific needs, I need to make the grid expand in full height of its wrapper

4条回答
  •  旧时难觅i
    2020-12-13 22:21

    According to one of Kendo's tech support team; Dimo Dimov. You should set the height of one container, and everything inside should be set to 100% (including the grid). Then you manually adjust the content height on document ready and window resize.

    See here for his example:

    http://jsfiddle.net/dimodi/SDFsz/

    See here for yours updated with a js function to set the height of the wrapper to the window height.

    http://jsbin.com/yumexugo/1/edit

    Essentially the content is resized with:

    function resizeGrid() {
        var gridElement = $("#grid"),
            dataArea = gridElement.find(".k-grid-content"),
            gridHeight = gridElement.innerHeight(),
            otherElements = gridElement.children().not(".k-grid-content"),
            otherElementsHeight = 0;
        otherElements.each(function(){
            otherElementsHeight += $(this).outerHeight();
        });
        dataArea.height(gridHeight - otherElementsHeight);
    }
    

    and the wrapper is sized with (you may need to modify this to suit your layout):

    function resizeWrapper() {
        $("#outerWrapper").height($('#body').innerHeight());
    }
    

    Document ready and window resize both call:

    $(window).resize(function() {
        resizeWrapper();
        resizeGrid();
    });
    

    Relevant css:

    #grid {
      height: 100%;
    }
    
    #outerWrapper{
      overflow: hidden;
    }
    

提交回复
热议问题