码迷,mamicode.com
首页 > Web开发 > 详细

整不明白Jquery的问题

时间:2014-07-18 17:29:07      阅读:284      评论:0      收藏:0      [点我收藏+]

标签:java   数据   io   for   问题   cti   

最近写个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的问题

标签:java   数据   io   for   问题   cti   

原文地址:http://www.cnblogs.com/hahabao/p/3853284.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!