/**//**
* 下移按钮
**/
downRow : 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 otr = tr;
if(tr.rowIndex == table.rows.length-1) ...{
alert("已经是最后一行了");
return false;
}
else ...{
table.moveRow(tr.rowIndex,tr.rowIndex+1);
this.isOdd = true;
var rows = table.tBodies[0].rows;
// 重新隔行换色
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;
}
}
// 实现AJAX调用处理下移
// 下移则把pars和pars2的值反过来,后台不变
var pars = "pars2=";
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 +"|";
}
}
}
var pars2 = "&pars=";
var uprow = table.rows[tr.rowIndex-1];
for(y=0;y<uprow.cells.length;y++) ...{
if(!css.elementHasClass(uprow.cells[y],'editbtn')&&!css.elementHasClass(uprow.cells[y],'delbtn')
&&!css.elementHasClass(uprow.cells[y],'updownbtn')) ...{
var colid = uprow.cells[y].getAttribute('columnId');
if(uprow.cells[y].firstChild.value!=null) ...{
pars2 += y +"^"+ uprow.cells[y].firstChild.value +"|";
}
else ...{
pars2 += y +"^"+ uprow.cells[y].innerText +"|";
}
}
}
pars3 = "&command=MoveUpDown&callback=afterUpdate&table="+table.id;
new Ajax.Updater('result','Dispatcher.ajax?'+pars+pars2+pars3,...{evalScripts: true});
}
}
function crudbtnInit() ...{
crudbtn.init();
}
// 回调: 处理结束后的反映
afterUpdate = function(e) ...{
if(e == 'true') ...{
}
else if(e == 'false') ...{
alert("您的操作失败了,请重新尝试");
window.location.reload();
}
else if(e == 'repeated') ...{
alert("您写入了重复的信息!请重新输入");
window.location.reload();
}
}
addEvent(window, 'load', crudbtnInit);
后台处理同 AjaxDelRow.cs
排序样式绑定JS:
/**//*
* Written by Wangzhongyuan
* 通过绑定sort样式进行后台排序的代码
*/
var sorting = ...{
that: false,
isOdd: false,
sortColumnIndex : -1,
lastAssignedId : 0,