+ -
当前位置:首页 → 问答吧 → 求高人指点JS table 自增行速度的问题

求高人指点JS table 自增行速度的问题

时间:2011-06-15

来源:互联网

部分代码


 
var cellb = document.getElementById("shttd_"+dataTable.endrow+"_"+dataTable.startcol);
var tbody = document.getElementById("table_sht").tBodies[0];
var oldTr = tbody.rows[cellb.parentNode.rowIndex];
var idx = oldTr.rowIndex;  
for(var x=0;x<dalength-rowold;x++){
dataTable.datarowcount ++; 
//?????
//onInsertRow(false);
idx++;
var newTr = tbody.insertRow(idx);
var cells = oldTr.cells;
for(var i=0;i<cells.length;i++)
{
cell = cells[i].cloneNode(true);
cell.id = "0";

var va=acVs[x][i+1];

if (va){
if(cell.getAttribute("cpceditable")){
var col = getDataCol(cell.getAttribute("cpccolid"));
col.setCellValue(cell, va);
}else{
var col = getDataCol(cell.getAttribute("cpccolid"));
col.setCellValue(cell, va);
 
}
}
newTr.appendChild(cell);
}

}
}
在操作自强5*24的表格居然需要24秒的时间。求高人指点呀

作者: a35031630   发布时间: 2011-06-15

dom操作效率是很低的 应尽量避免频繁dom操作

http://www.cnblogs.com/aaa/articles/1358161.html

作者: inetfuture   发布时间: 2011-06-15

热门下载

更多