Setting Kendo UI grid height 100% of wrapper

后端 未结 4 1092
无人共我
无人共我 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条回答
  •  攒了一身酷
    2020-12-13 22:11

    You have to do two things.

    1. Adjust the $('.k-grid table') height on page resize
    2. Adjust the $('.k-grid table') height on dataBound method of grid

    Please see it in jsBin http://jsbin.com/xorawuya/1/edit

      $(window).resize(function() {
        var viewportHeight = $(window).height();
        $('#outerWrapper').height(viewportHeight);
        $('.k-grid table').height(viewportHeight-150);
      });
    

    And also here

      dataBound: function(e) {
        $('.k-grid table').height($(window).height()-150);
      },
    

    The 150 which I am subtracting is the height of window minus height of the grid header/footer. This could be different in your website layout. Adjust it accordingly.

提交回复
热议问题