Implement CSS based AJAX development with. NET (3)

Source: Internet
Author: User
Tags implement modify
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 = "Move Up";
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 = "Move Down";
Table.tbodies[0].rows[j+1].cells[k].appendchild (LINKEL2);
}
}

}
Alternate colors, depending on odd style
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]);
}
},
/**//**
* Interlace separations policy, depending on odd style
**/
Dostripe:function (Rowitem) ... {
if (!this.isodd) ... {
Css.addclasstoelement (Rowitem, ' odd ');
else ... {
Css.removeclassfromelement (Rowitem, ' odd ');
}

this.isodd =!this.isodd;
},
/**//**
* Delete Target column
**/
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;

Implement AJAX call Processing Delete
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);

Change the color of a new interlacing
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 ("The page has no data, the system will overload the data item");
window.location = "?";
}
},
/**//**
* Modify button
**/
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;

var cellcount = tr.cells.length;
If you don't click Modify
if (Tr.getattribute (' editing ')!=1) ... {
for (Var o=0;o<cellcount;o++) ... {
If the column contains a modified style, delete style, or other similar style, the column is ignored
if (!css.elementhasclass (Tr.cells[o], ' editbtn ') &&!css.elementhasclass (Tr.cells[o], ' delbtn ')
&&!css.elementhasclass (Tr.cells[o], ' updownbtn ') &&!css.elementhasclass (tr.cells[o), ' Noedit ') ... {
var Inputel = createelement (' input ');
Inputel.type = "text";
text box size
Inputel.size = tr.cells[o].innertext.length*2; Inputel.size = Tr.cells[o].innertext.replace (/[^\x00-\xff]/gi, ' xx '). length;
Tr.cells[o].setattribute (' columnId ', O);
Inputel.setattribute (' OldValue ', tr.cells[o].innerhtml);
var inputels = Tr.cells[o].innertext;
Inputel.value = Inputels;
Tr.cells[o].firstchild.removenode (TRUE);
Tr.cells[o].appendchild (Inputel);
Tr.setattribute (' editing ', 1);
Linkel.setattribute (' OldValue ', linkel.innertext);
}
}
Linkel.innertext = "OK";

var p = createelement (' span ');
p.innerhtml = "";
Td.appendchild (P);

var linkEl2 = createelement (' a ');
linkel2.href= "#";
Linkel2.onclick = That.cancelrow;
Linkel2.innertext = "Cancel";
Td.appendchild (LINKEL2);
}



Related Article

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.