var linkEl = createElement('a');
linkEl.href = '#';
linkEl.onclick = this.upRow;
linkEl.setAttribute('columnId', k);
var innerEls = table.tBodies[0].rows[j+1].cells[k].childNodes;
linkEl.innerText = "上移";
table.tBodies[0].rows[j+1].cells[k].appendChild(linkEl);
var p = createElement('span');
p.innerHTML = " ";
table.tBodies[0].rows[j+1].cells[k].appendChild(p);
var linkEl2 = createElement('a');
linkEl2.href = '#';
linkEl2.onclick = this.downRow;
linkEl2.setAttribute('columnId', k);
var innerEls2 = table.tBodies[0].rows[j+1].cells[k].childNodes;
linkEl2.innerText = "下移";
table.tBodies[0].rows[j+1].cells[k].appendChild(linkEl2);
}
}
}
// 隔行换颜色,依赖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) ...{
&nb