easyuidatagrid行高自适应

网上查了半天没有查到,只有通过css进行,于是想那通过js控制不也就可以了么?

<style>
        .grid-panel .datagrid-btable tr{height: 40px;}
    </style>
 
 
<div class="grid-panel" style="width: 100%;height: 100%">
<table id="dg-worker"></table>
</div>

target为需要自动行高的datagrid $("#mytable")

exceptHeight是根据你当前页面进行判定的,

styleObject为css的选择器$("#RegionCenter .datagrid-row")

 

function autoRowHeight(target, exceptHeight, styleObject) {
	if (exceptHeight == null) {
		exceptHeight = 108;
		currentHeight = document.body.offsetHeight - exceptHeight;
		var pagesize = target.datagrid('getPager').data("pagination").options.pageSize;
		styleObject.css("height",currentHeight/pagesize)
	}else {
		currentHeight = document.body.offsetHeight - exceptHeight;
		var pagesize = target.datagrid('getPager').data("pagination").options.pageSize;
		styleObject.css("height",currentHeight/pagesize);
	}
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章