append方法效率太差了,高手帮忙看下
时间:2009-03-26
来源:互联网
function drawDataSourceBodyTable(){
var dataSourceBodyTableTr=I('dataSourceBodyTable tr[id]');
dataSourceBodyTableTr.remove();
var row,cell,dataIndex,dataObject,timeYMD,dataLevel,innerText,appendHTML;
for(dataIndex=0;dataIndex<dataSource.length;dataIndex++){
appendHTML="";
dataObject=dataSource[dataIndex];
dataLevel=getDataLevelByVersion(dataObject.version);
innerText=dataIndex+1;
I('dataSourceBodyTable').append("<tr id='row_"+dataIndex+"' rid='"+dataIndex+"' dataLevel='"+dataLevel+"' style='height:"+gantShowTdHeight+"px;'></tr>");
appendHTML="<td id='"+dataIndex+",0"+"' style='width:30px;backgroundColor:whitesmoke'>"+innerText+
"</td><td id='"+dataIndex+",1"+"' style='width:270px'><table border='0' cellspacing='0' cellpadding='0'><tr><td style='width:"+parseInt(dataLevel*20)+"px'></td><td style='borderWidth:0'>";
if(dataSource[dataIndex+1]!=null&&getDataLevelByVersion(dataSource[dataIndex+1].version)>dataLevel){
dataSourceBodyTableTr.attr('isSummary','1');
appendHTML+="<img id='img_"+dataIndex+"' src='"+openDir+"' onclick='changeTree()' rid="+dataIndex+">";
}
else{
appendHTML+='';
dataSourceBodyTableTr.attr('isSummary','0');
}
appendHTML+="</td><td style='borderWidth:0px'>"+dataObject.taskName.substr(0,20)+"</td></tr></table></td>";
appendHTML+="<td id='"+dataIndex+",2"+"' style='Width:100px'>"+getDaysBetweenStartAndEnd(dataObject.planStart,dataObject.planEnd)+"</td>";
timeYMD=dataObject.planStart.split('-');
I('row_'+dataIndex).attr('planStart',settimeSpanStart(timeYMD));
appendHTML+="<td id='"+dataIndex+",3"+"' style='Width:100px'>"+timeYMD[0]+'年'+timeYMD[1]+'月'+timeYMD[2]+'日'+"</td>";
timeYMD=dataObject.planEnd.split('-');
appendHTML+="<td id='"+dataIndex+",4"+"' style='Width:100px'>"+timeYMD[0]+'年'+timeYMD[1]+'月'+timeYMD[2]+'日'+"</td>";
appendHTML+="<td id='"+dataIndex+",5"+"' style='Width:100px'>"+dataObject.resources.substr(0,8)+"</td>";
I('row_'+dataIndex).attr('planEnd',settimeSpanEnd(timeYMD));
I('row_'+dataIndex).attr('excuteStart',getTimeByYMD(dataObject.excuteStart.split('-')));
I('row_'+dataIndex).attr('excuteEnd',getTimeByYMD(dataObject.excuteEnd.split('-')));
I('row_'+dataIndex).attr('resources',dataObject.resources);
I('row_'+dataIndex).attr('level',dataLevel);
I('row_'+dataIndex).html(appendHTML);
}
realTimeStart=timeSpanStart;
realTimeEnd=timeSpanEnd;
}
var dataSourceBodyTableTr=I('dataSourceBodyTable tr[id]');
dataSourceBodyTableTr.remove();
var row,cell,dataIndex,dataObject,timeYMD,dataLevel,innerText,appendHTML;
for(dataIndex=0;dataIndex<dataSource.length;dataIndex++){
appendHTML="";
dataObject=dataSource[dataIndex];
dataLevel=getDataLevelByVersion(dataObject.version);
innerText=dataIndex+1;
I('dataSourceBodyTable').append("<tr id='row_"+dataIndex+"' rid='"+dataIndex+"' dataLevel='"+dataLevel+"' style='height:"+gantShowTdHeight+"px;'></tr>");
appendHTML="<td id='"+dataIndex+",0"+"' style='width:30px;backgroundColor:whitesmoke'>"+innerText+
"</td><td id='"+dataIndex+",1"+"' style='width:270px'><table border='0' cellspacing='0' cellpadding='0'><tr><td style='width:"+parseInt(dataLevel*20)+"px'></td><td style='borderWidth:0'>";
if(dataSource[dataIndex+1]!=null&&getDataLevelByVersion(dataSource[dataIndex+1].version)>dataLevel){
dataSourceBodyTableTr.attr('isSummary','1');
appendHTML+="<img id='img_"+dataIndex+"' src='"+openDir+"' onclick='changeTree()' rid="+dataIndex+">";
}
else{
appendHTML+='';
dataSourceBodyTableTr.attr('isSummary','0');
}
appendHTML+="</td><td style='borderWidth:0px'>"+dataObject.taskName.substr(0,20)+"</td></tr></table></td>";
appendHTML+="<td id='"+dataIndex+",2"+"' style='Width:100px'>"+getDaysBetweenStartAndEnd(dataObject.planStart,dataObject.planEnd)+"</td>";
timeYMD=dataObject.planStart.split('-');
I('row_'+dataIndex).attr('planStart',settimeSpanStart(timeYMD));
appendHTML+="<td id='"+dataIndex+",3"+"' style='Width:100px'>"+timeYMD[0]+'年'+timeYMD[1]+'月'+timeYMD[2]+'日'+"</td>";
timeYMD=dataObject.planEnd.split('-');
appendHTML+="<td id='"+dataIndex+",4"+"' style='Width:100px'>"+timeYMD[0]+'年'+timeYMD[1]+'月'+timeYMD[2]+'日'+"</td>";
appendHTML+="<td id='"+dataIndex+",5"+"' style='Width:100px'>"+dataObject.resources.substr(0,8)+"</td>";
I('row_'+dataIndex).attr('planEnd',settimeSpanEnd(timeYMD));
I('row_'+dataIndex).attr('excuteStart',getTimeByYMD(dataObject.excuteStart.split('-')));
I('row_'+dataIndex).attr('excuteEnd',getTimeByYMD(dataObject.excuteEnd.split('-')));
I('row_'+dataIndex).attr('resources',dataObject.resources);
I('row_'+dataIndex).attr('level',dataLevel);
I('row_'+dataIndex).html(appendHTML);
}
realTimeStart=timeSpanStart;
realTimeEnd=timeSpanEnd;
}
作者: xwz7534658 发布时间: 2009-03-26
少用append方法
先创建数据字符串
最后调用一次append添加到document当中
可以看论坛这个帖子 我在2楼的回帖
http://bbs.jquery.org.cn/read.php?tid-4206.html
先创建数据字符串
最后调用一次append添加到document当中
可以看论坛这个帖子 我在2楼的回帖
http://bbs.jquery.org.cn/read.php?tid-4206.html
作者: gordianyuan 发布时间: 2009-03-26
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28