javascript 动态创建表格

function createTable()

{

   var serch = document.createElement("TABLE");//指定创建的是Table (创建什么指定  什么:DIV...)
   serch.id="searchGrid";//指定table名子
   serch.cellPadding = "0";
   serch.cellSpacing="0";
   var rRow = serch.insertRow();//创建行
   rRow.vAlign="top";//字体属性:Top,Bottom,Center
   var curCell = rRow.insertCell();//创建列
   curCell.width="24";//指定宽
   curCell.style.borderBottom="2px solid #BED6E0";//指定下边框颜色 宽度
   curCell.style.textAlign="center";//指定某一列字体属性
   curCell.style.paddingTop = "11px";//某一列距离上边框高度
   searchNode.appendChild(serch);//HTML节点searchNode处,创建Table.searchNode           为HTML节点

//循环插入数据

  for(var i=0; i<list.length; i++)
   {
   
   var l = list[i].map;
   var mRow = searchGrid.insertRow();
   mRow.style.paddingLeft="4px";
   mRow.style.paddingTop="5px";
   mRow.style.paddingBottom="4px";
   mRow.style.cursor="hand";
   
   mRow.οnclick=Function("changeGridColor(this,searchGrid,searchGrid0);");
   mRow.οndblclick=Function("top.newLabel(this.openText, this.url)");
   mRow.openText="工作任务";
   mRow.url="task_index.fp?Vid="+l.id;
   
   var curCell = mRow.insertCell();
   mRow.insertCell();
   curCell.innerHTML =  "<span style='overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100%;'>"+ (l.lastModifyDate == undefined ? "" : l.lastModifyDate.substring(2)) +"</span>";
   
   var curCell0 = mRow.insertCell();
   mRow.insertCell();
   curCell0.innerHTML = "<span style='overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100%;'>"+ (l.rw0101 == undefined ? "" : l.rw0101) +"</span>";
   
   var curCell1 = mRow.insertCell();
   mRow.insertCell();
   curCell1.innerHTML = "<span style='overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100%;'>"+ (l.rw0103 == undefined ? "" : l.rw0103) +"</span>";
   
   var curCell2 = mRow.insertCell();
   mRow.insertCell();
   curCell2.innerHTML = "<span style='overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100%;'>"+ (l.rw0106 == undefined ? "" : l.rw0106)+"</span>";
  }

 

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值