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);
	}
}

 

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