全編輯WebGrid控制項LrcGrid(4)—— 指令碼庫和樣式表

來源:互聯網
上載者:User
web|指令碼|控制項|樣式表 全編輯WebGrid控制項LrcGrid(4)—— 指令碼庫和樣式表

指令碼庫:包含了控制項用戶端操作的函數.包括:

將表格行切換到編輯模式的函數:chgEditRow(rowIndex,tab)()
將表格列切換到編輯模式的函數:chgEdit(colIndex,tab)
在用戶端構造更新資料庫的sql語句: BuildSql(tabName)
添加新記錄的函數:AddRow(tab)
移除新添加行的函數: RemoveRow(tab)
全部js代碼:


function chgEditRow(rowIndex,tab)
{
var tabBody = tab.tBodies[0];
var isE = 0;
//alert(rowIndex);
//alert(tabBody.rows[rowIndex].cells.length);
for(var i = 0;i< tabBody.rows[rowIndex].cells.length;i++)
{
//alert(tabBody.rows[rowIndex].cells[i].childNodes[0].id);
if(tabBody.rows[rowIndex].cells[i].hasChildNodes())
{

if(tabBody.rows[rowIndex].cells[i].childNodes[0].nodeType != 3)
{
if(tabBody.rows[rowIndex].cells[i].childNodes[0].id.indexOf('LrcTb_') != -1)
{
if(!tabBody.rows[rowIndex].cells[i].childNodes[0].disabled)
{
tabBody.rows[rowIndex].cells[i].childNodes[0].disabled = true;
tabBody.rows[rowIndex].cells[i].childNodes[0].className = "lrc_txt_hid";
}
else
{
tabBody.rows[rowIndex].cells[i].childNodes[0].disabled = false;
tabBody.rows[rowIndex].cells[i].childNodes[0].className = "lrc_txt_show";
}
}
else if(tabBody.rows[rowIndex].cells[i].childNodes[0].id.indexOf('LrcDrl_') != -1)
{
if(!tabBody.rows[rowIndex].cells[i].childNodes[0].disabled)
{
tabBody.rows[rowIndex].cells[i].childNodes[0].disabled = true;
}
else
{
tabBody.rows[rowIndex].cells[i].childNodes[0].disabled = false;
}
}
}
}
}
}
function chgEdit(colIndex,tab)
{
var tabBody = tab.tBodies[0];
var oneRow;
if(tabBody.rows[1].cells[colIndex].childNodes[0].disabled)
{
for(var i=1;i<tabBody.rows.length-1;i++)
{
oneRow = tabBody.rows[i];
if(oneRow.cells[colIndex].childNodes[0].id.indexOf('LrcTb_') != -1)
{
oneRow.cells[colIndex].childNodes[0].disabled = false;
oneRow.cells[colIndex].childNodes[0].className = "lrc_txt_show";
}
else if(oneRow.cells[colIndex].childNodes[0].id.indexOf('LrcDrl_') != -1)
{
oneRow.cells[colIndex].childNodes[0].disabled = false;
}
}
}
else
{
for(var i=1;i<tabBody.rows.length-1;i++)
{
oneRow = tabBody.rows[i];
if(oneRow.cells[colIndex].childNodes[0].id.indexOf('LrcTb_') != -1)
{
oneRow.cells[colIndex].childNodes[0].disabled = true;
oneRow.cells[colIndex].childNodes[0].className = "lrc_txt_hid";
}
else if(oneRow.cells[colIndex].childNodes[0].id.indexOf('LrcDrl_') != -1)
{
oneRow.cells[colIndex].childNodes[0].disabled = true;
}
}
}
}
function BuildSql(tabName)
{
var UpdSql = '';
var tabBody = tabName.tBodies[0];
var oneRow;
var len = tabBody.rows.length;
var celLen = tabName.rows[0].cells.length;
var isadd = tabName.getAttribute("isadd");
var isdel = tabName.getAttribute("isdel");
if(isdel == 'True')
{
celLen = celLen -1;
}

var hidIndex = 0;
if(isadd == 'True')
{
hidIndex = 2;
}
var tabN = tabBody.rows[len-1].cells[hidIndex].childNodes[1].value;
var colN = tabBody.rows[len-1].cells[hidIndex].childNodes[2].value;
var colNA = colN.split(",");
var priK = tabBody.rows[len-1].cells[hidIndex].childNodes[3].value;
var priKA = priK.split(",");
var editCol = tabBody.rows[len-1].cells[hidIndex].childNodes[4].value;
var editColA;
if(editCol == 'LrcAllEdit')
{
var len = colNA.length - priKA.length;
editColA = new Array(len);
var indexE = 0;
for(var i = 0 ; i< colNA.length ; i++)
{
var isPri = 0;
for(var j=0;j<priKA.length;j++)
{
if(priKA[j] == i)
{
isPri = 1;
}
}
if(isPri == 0)
{
editColA[indexE] = i;
indexE++;
}
}
}
else
{
editColA = editCol.split(",");
}

var strUpd = "UPDATE " + tabN + " SET ";
var strIns = "INSERT " + tabN + " (" + colN + ") VALUES ( ";
for(var i=1;i<tabBody.rows.length-1



相關文章

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。