2014-09-25 120 views
4

我想要获得具有静态高度和宽度的Kendo网格。 当我页面时(它目前所做的,由于可变大小的数据)绝对不能改变高度和宽度。 如果数据增加,我应该提供滚动。如何将Kendo网格高度设置为页面加载时的固定值

问题是,当页面首次加载数据时,剑道网格未设置为固定的高度和宽度。 但如果我调整它越来越是固定的高度,提供了剑道网格内滚动选项

所以我可以我设置的高度剑道格在一个固定值窗口时,它加载首次

剑道版本:v2014.1.318

代码:

$("#ViewUnitContainerTracking").kendoGrid({ 
         sortable: true, 
         height:"280px", 

         columns: [ 
          { 
           field: "UnitCode", 
           title: "Unit", 
           width: "15%" 
          }, 

          { 
           field: "UnitName", 
           title: "Unit Name", 
           width: "35%" 
          }, 

          { 
           field: "Status", 
           title: "St", 
           width: "5%", 
           template: $("#TemplateViewUnitTrackingStatus").text() 
          }, 

          { 
           field: "StartDate", 
           title: "Start Date", 
           //template: $("#TemplateViewUnitTrackingStartDate").text(), 
           width: "15%", 
           //type: "date" 
          }, 

           { 
            field: "EndDate", 
            title: "End Date", 
            //template: $("#TemplateViewUnitTrackingEndDate").text(), 
            width: "15%", 
            //type: "date" 
           }, 

          { 
           field: "AssessPrgress", 
           title: "%OAP", 
           width: "10%" 
          }, 
          { 
           field: "Status", 
           title: "Status", 
           hidden: true 
          } 

         ], 
         editable: false, 
         resizable: false, 
         mobile: true, 
         dataSource: data.UnitList 
        }); 

HTML页面:

<div id="ViewUnitContainerTracking" style="padding-top:10px;"> 
</div> 
问题10
+0

你能展示一些代码来重现它吗? – OnaBai 2014-09-25 11:18:00

+0

我已编辑帖子。现在它的代码部分为 – bhakti 2014-09-25 13:37:42

回答

4

答案是: -

dataBound: function() { 
    $('#ViewUnitContainerTracking .k-grid-content').height(280); 
} 

添加这剑道电网将解决这一问题。 由于数据绑定事件我们可以设置网格的自定义Css属性,因为在此事件之前设置了网格动态高度。

+4

或者您可以在页面加载时调用** resize **方法:$(“#ViewUnitContainerTracking”)。data(“kendoGrid”)。resize() – Meister 2014-09-26 02:46:37

2

我米动态这样做,以网格设定为100%,装置,引导减去页眉和页脚:

<script type="text/javascript"> 
    var gridElement = $("#serviceGrid");  
    function resizeGrid() { 
     $("#serviceGrid").css("height", $(window).height() - $("#itheader").height() - $("#itfooter").height() - 2); 
     gridElement.data("kendoGrid").resize(); 
    }  
    $(window).resize(function() { 
     resizeGrid(); 
    }); 
</script> 

的“ - 2”,是因为两个1px的边框的顶部和底部..

相关问题