Full edit WebGrid Control Lrcgrid (4)--script library and style sheet

Source: Internet
Author: User
Tags split client
web| Script | control | style sheet full edit WebGrid control Lrcgrid (4)--script library and style sheet

Script Library: A function that contains a control client action. Including:

function to switch table rows to edit mode: Chgeditrow (Rowindex,tab) ()
function to switch table columns to edit mode: Chgedit (Colindex,tab)
To construct an SQL statement that updates a database on a client: BuildSQL (tabname)
Functions to add new records: addrow (tab)
Remove the newly added row function: removerow (tab)
All JS code:


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



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.