} // 隔行换颜色,依赖odd样式 this.isodd = true; var rows = table.tbodies[0].rows;
// we appendchild rows that already exist to the tbody, so it moves them rather than creating new ones for (var i=0;i<rows.length-1;i++) ...{ this.dostripe(rows[i+1]); } }, /**//** * 隔行分色策略,依赖odd样式 **/ dostripe : function(rowitem) ...{ if (!this.isodd) ...{ css.addclasstoelement(rowitem, 'odd'); } else ...{ css.removeclassfromelement(rowitem, 'odd'); }
this.isodd = !this.isodd; }, /**//** * 删除目标列 **/ delrow : function(e) ...{ var that = crudbtn.that; var linkel = geteventtarget(e); var td = linkel.parentnode; var tr = td.parentnode; var thead = tr.parentnode; var table = thead.parentnode;
if (!table.tbodies || table.tbodies[0].rows.length <= 1) ...{ return false; }
this.isodd = true; var rows = table.tbodies[0].rows;
// 实现ajax调用处理删除 var pars = "pars="; for(h=0;h<tr.cells.length;h++) ...{ if(!css.elementhasclass(tr.cells[h],'editbtn')&&!css.elementhasclass(tr.cells[h],'delbtn') &&!css.elementhasclass(tr.cells[h],'updownbtn')) ...{ var colid = tr.cells[h].getattribute('columnid'); if(tr.cells[h].firstchild.value!=null) ...{ pars += h +"^"+ tr.cells[h].firstchild.value +"|"; } else ...{ pars += h +"^"+ tr.cells[h].innertext +"|"; } } } pars += "&command=delrow&callback=afterupdate&table="+table.id; table.deleterow(tr.rowindex);
// 重新隔行换色 for (var i=1;i<rows.length;i++) ...{ if (!this.isodd) ...{ css.addclasstoelement(rows[i], 'odd'); } else ...{ css.removeclassfromelement(rows[i], 'odd'); } this.isodd = !this.isodd; } new ajax.updater('result','dispatcher.ajax?'+pars,...{evalscripts: true}); if(table.rows.length<=1) ...{ alert("该页已无数据,系统将重载数据项"); window.location = "?"; } }, /**//** * 修改按钮 **/ editrow : function(e) ...{ var that = crudbtn.that; var linkel = geteventtarget(e); var td = linkel.parentnode; var tr = td.parentnode; var thead = tr.parentnode; var table = thead.parentnode;
var column = linkel.getattribute('columnid') || td.cellindex;