客户端实现类似于DataGrid的输入表格控件[3]

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 curllion 的 blog

//画出表格
clientdatagrid.prototype.draw = function(id)
{
     this.id=id;
     var str = "<table rules='all' id = '" + id + "_datagrid' " +
     (this.border       !=null?("border=" + this.border):"") + " " +
     (this.cellspace    !=null?("cellspace=" + this.cellspace):"") + " " +
     (this.cellpadding  !=null?("cellpadding=" +this.cellpadding):"") + " " +
     (this.width        !=null?("width=" + this.width):"") + " " +
     (this.height       !=null?("height=" + this.height):"") + " " +
     (this.bordercolor  !=null?("bordercolor=" + this.bordercolor):"") + " " +
     (this.css          !=null?("style='" + this.css + "'"):"") + ">";
     //画标题
     str = str + "<tr " + (this.titlecss!=null?("style='" + this.titlecss + "'"):"") + ">";
     for(var i = 0;i<this.colcount;i++)
     {
         str = str + "<td " + (this.colwidths[i]!=null?("width=" + this.colwidths[i]):"") + " " +
         (this.titleitemcss!=null?("style='" + this.titleitemcss + "' "):"") + ">" + this.titlerow[i] + "</td>";
     }
     str = str + "<td " + (this.titleitemcss!=null?("style='" + this.titleitemcss + "' "):"") + ">选中</td>";
     str = str + "<td " + (this.titleitemcss!=null?("style='" + this.titleitemcss + "' "):"") + ">删除</td>";
     str = str + "</tr>" ;
     //画单元格
     for(var i = 0 ; i < this.rowcount; i++)
     {
         str = str + "<tr id = 'row"+ i + "' " + (this.rowheight!=null?("height=" + this.rowheight):"") + " " +
         (this.rowcss!=null?("style='" + this.rowcss + "'"):"") + ">";
         for(var j=0;j<this.colcount;j++)
         {
             if(this.inputcols[j] == 1)
                 str = str + "<td " + (this.itemcss!=null?("style='" + this.itemcss + "' "):"") + "><input language='javascript' type=text value='" + this.rows[i].data[j] + "' onblur='"+this.id+".cellchange("+j+","+i+",this.value)'></td>";
             if(this.inputcols[j] == 0)
                 str = str + "<td " + (this.itemcss!=null?("style='" + this.itemcss + "' "):"") + ">" + this.rows[i].data[j] + "</td>";
         }
         str = str + "<td " + (this.itemcss!=null?("style='" + this.itemcss + "' "):"") + "><input language='javascript' type=button value='选中' onclick='" + this.id + ".selectrow(" + i + ")'></td>";
         str = str + "<td " + (this.itemcss!=null?("style='" + this.itemcss + "' "):"") + "><input language='javascript' type=button value='删除' onclick='" + this.id + ".deleterowat("+ i + ")'></td>";
         str = str + "</tr>";
     }
     str = str + "</table>";
     thi

本文关键:客户端实现类似于DataGrid的输入表格控件
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top