(document,'mousemove',this.widtharg.widthmove); removeListener(document,'mouseup',this.widtharg.widthup); }, closdrag : function(e){ e = e || window.event; var obj = e.srcElement ||e.target; if(obj.nodeName.toLowerCase()=="span")obj =obj.parentNode; this.closarg.tdnum = obj.getAttribute('clos');; addListener(document,'mousemove',this.closarg.closmove); addListener(document,'mouseup',this.closarg.closup); }, closmove : function(e){ window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty(); Css(this.img,{display:"block",left:e.clientX+9+"px",top:e.clientY+20+"px"}); }, closup : function(){ this.img.style.display = "none"; removeListener(document,'mousemove',this.closarg.closmove); removeListener(document,'mouseup',this.closarg.closup); if(this.closarg.totdnum==this.closarg.tdnum)return; var rows =this.table.getElementsByTagName('tr'),tds,n,o; if((parseInt(this.closarg.tdnum)+1)==parseInt(this.closarg.totdnum)) { o = this.closarg.tdnum; n = this.closarg.totdnum; } else { n = this.closarg.tdnum; o = this.closarg.totdnum; } for(var i=0,l=rows.length;i<l;i++) { tds = rows[i].getElementsByTagName('td'); try{ rows[i].insertBefore(tds[n],tds[o]); } catch(err){ return; } } for(var i=0,l=this.theadtds.length;i<l;i++) this.theadtds[i].setAttribute('clos',i); }, edit: function(e){ var o = e.srcElement || e.target; if(!o.getAttribute('edit'))return; this.inputtd = o; var v = o.innerHTML; o.innerHTML = ""; o.appendChild(this.input); this.input.value=v; this.input.focus(); }, save : function(o){ var edit=this.edits[o.parentNode.getAttribute('edit')]; if(edit.rule.test(this.input.value)){ this.inputtd.innerHTML = this.input.value; this.inputtd=null; }else{ alert(edit.message); } }, sortTable :function(td,n,type){ var frag=document.createDocumentFragment(),str= td.getElementsByTagName('span')[0].innerHTML,span=td.getElementsByTagName('span')[0]; if(this.row!=null||td==this.sortCol){ this.rows.reverse(); span.innerHTML =str.replace(/.$/,str.charAt(str.length-1)=="↓"?"↑":"↓") ; }else{ this.rows.sort(this.compare(n,type)); span.innerHTML = span.innerHTML + "↑"; this.sortCol!=null&&(this.sortCol.getElementsByTagName('span')[0].innerHTML = this.sortCol.getElementsByTagName('span')[0].innerHTML.replace(/.$/,'')); }; for(var i=0,l=this.rows.length;i<l;i++) frag.appendChild(this.rows[i]); this.table.tBodies[0].appendChild(frag); if(Sys.IE6){ for(var s in this.checkbox) this.checkbox[s].checked = true; } this.sortCol = td; }, compare :function(n,type){ return function (a1,a2){ var convert ={ int : function(v){return parseInt(v)}, float : function(v){return parseFloat(v)}, date : function(v){return v.toString()}, string : function(v){return v.toString()} }; !convert[type]&&(convert[type]=function(v){return v.toString()}); a1 =convert[type](a1.cells[n].innerHTML); a2 =convert[type](a2.cells[n].innerHTML); if(a1==a2)return 0; return a1<a2?-1:1; }; } }); window.onload = function(){ var set = [ {id:0,type:"int"}, {id:2,type:"string",edit:{rule:/^([a-z]|[\u4e00-\u9fa5]){2,}$/i,message:"请输入2位以上的汉字,或者是字母"}}, {id:3,type:"date",edit:{rule:/^\d{4}\-\d{2}\-\d{2}$/,message:"按这中格式输入日期1985-02-30"}}, {id:4,type:"string",edit:{rule:/^.{4,10}$/,message:"请输入4到10个字符"}} ]; new Table($("tab"),set); } </script> </body> </html>
最后加载set的时候没有添加!!!把最后的window.onload添加最后两项。
window.onload = function(){ var set = [ {id:0,type:"int"}, {id:2,type:"string",edit:{rule:/^([a-z]|[\u4e00-\u9fa5]){2,}$/i,message:"请输入2位以上的汉字,或者是字母"}}, {id:3,type:"date",edit:{rule:/^\d{4}\-\d{2}\-\d{2}$/,message:"按这中格式输入日期1985-02-30"}}, {id:4,type:"string",edit:{rule:/^.{4,10}$/,message:"请输入4到10个字符"}}, {id:5,type:"string",edit:{rule:/^.{4,10}$/,message:"请输入4到10个字毕业论文 符"}}, {id:6,type:"string",edit:{rule:/^.{4,10}$/,message:"请输入4到10个字符"}} ]; new Table($("tab"),set); }
上一页 [1] [2]