Wednesday, November 27, 2013

Adding,Deleting Row in gridview using Jquery (Very Effective)


Records
Company Product Model State City Quantity Contact Mail ID


Select
Jqueyy code: $(document).ready( function () { $("#DuplicateRow").click( function () { var checkboxValues = []; $('input[type="checkbox"]:checked').each( function () { var $chkbox = $(this); var $actualrow = $chkbox.closest('tr'); var $clonedRow = $actualrow.clone(); $clonedRow.find("select").each( function (i) { this.selectedIndex = $actualrow.find("select")[i].selectedIndex; } ) $chkbox.closest('#tabletomodify').append($clonedRow); } ); } ); $("#DeleteRow").click( function () { var checkboxValues = []; $('input[type="checkbox"]:checked').each( function () { var $chkbox = $(this); $(this).closest("tr").remove(); } ); } ); $("#AddRow").click( function () { var row = document.getElementById("row"); // find row to copy var table = document.getElementById("tabletomodify"); // find table to append to var clone = row.cloneNode(true); // copy children too clone.id = "row"; // change id or other attributes/contents table.appendChild(clone); // add new row to end of table } ); $('#tabletomodify').on('change','.selcompany', function () { var optionSelected = $("option:selected", this); var valueSelected = this.value; alert(valueSelected); }); } );

No comments:

Post a Comment