最近写个GridView,由于不是很熟悉javascript,用jquery实现后,发现下面设置左右表行高的代码如果不把行保存
在$tr1,$tr2中再设置css,速度非常慢,300行50列左右的数据得1分钟左右,如下修改后只要7,8秒。各位大大看看能否帮忙分析一下。
$fixedTrs固定列的行,$freeTrs非固定列行。
function resetRowHeight ($fixedTrs, $freeTrs){
var rhs = [], l1 = $fixedTrs.length, l2 = $freeTrs.length,
$tr1 = [], $tr2 = [], minheight = parseInt(this.options.minRowHeight, 10) || 0;
isNaN(minheight) && (minheight = 0);
for (var i = 0; i < l2; i++) {
var tr1, tr2;
$tr2[i] = tr2 = $freeTrs.eq(i).css({ "max-height": "", "height": "" });
var rh = Math.max(minheight, tr2.children().height());
if (l1 == l2) {
$tr1[i] = tr1 = $fixedTrs.eq(i).css({ "max-height": "", "height": "" });
rh = Math.max(rh, tr1.children().height());
}
rhs[i] = rh;
}
for (var j = 0; j < l2; j++) {
var cssArgs = { "max-height": (rhs[j] + 2) + "px", "height": (rhs[j] + 2) + "px" };
if (l1 == l2) {
$tr1[j].css(cssArgs);
}
$tr2[j].css(cssArgs);
}
}
整不明白Jquery的问题,布布扣,bubuko.com
整不明白Jquery的问题