简体   繁体   English

自动调整剑道网格高度

[英]Adjust Kendo-Grid height automatically

I would like to adjust the Kendo-Grid height automatically such as the bottom grid is at 20px from the bottom of the window.我想自动调整剑道网格高度,例如底部网格距离窗口底部 20 20px

.--------------------. - 
| Navbar             | |
|   .------------.   | |
|   | Kendo-Grid |   | | Window Height
|   |            |   | |
|   '------------'   | |
'--------------------' -

My current solution uses Javascript:我当前的解决方案使用 Javascript:

<div class="container-fluid">
    <div id="grid"></div>
</div>

<script>
    $(window).resize(function() {
        let height = window.innerHeight - $('#grid').offset().top - 20
        $('#grid').css('height', height + 'px')
        $('#grid').data("kendoGrid").refresh()
    })
</script>

I am wondering if there is a better solution.我想知道是否有更好的解决方案。

I'm assuming here, as your layout might be more specific, but you can try this CSS:我在这里假设,因为您的布局可能更具体,但您可以试试这个 CSS:

<style>
    .container-fluid {
        height: 100%;
    }
    #grid {
        height: calc(100% - 20px);
    }
</style>

<div class="container-fluid">
    <div id="grid"></div>
</div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM