in my code below i can edit row success without any error but if i need to cancel value edited in row OR get value before changed what i write to cancel edit in row in table by using jquery my code as following
@{
Layout = null;
}
$(function () {
$("#btn").click(function ()
{
var x = $("#txt1").val();
var y = $("#txt2").val();
var z = $("#mycountry").val();
$("#tb").append(" " + x + " " + y + " " + z + " ");
});
$("#tb").on("click", ".c", function () {
//$(this).parent().parent().remove();
$(this).closest('tr').remove();
});
$("#tb").on("click", ".d", function () {
var row = $(this).closest('tr').toggleClass("editing");
row.find("td").slice(0, 2).prop("contenteditable", row.hasClass("editing"));
var myselect = '
'' + '' + '' + '' + ''
'';
var dropcountry = $(this).parent().prev().prev().text;
$(this).parent().prev().prev().html(myselect);
//$('#tb').append(myselect);
// $("#tb").children().children().eq(3).children().eq(3).append("myselect");
});
$("#btndis").on('click', function () {
$("body").append("
$('#tb td:nth-child(2)').each(function () {
$("#listNames").append("" + $(this).text() + " ")
});
});
});
.editing {
background: yellow;
}
ID
Name
Country:
ID | Name | Country |
Amar GaikwadPosted Jul 26, 2016, 1:38 PM
- You can declare 3 variables in JavaScript for storing the initial values when user clicks on 'Edit' button.
- When user clicks on 'Edit' button set the assign the current values from edited row to these 3 variables.
- If user clicks on 'Update' button then do not take any action.
- If user clicks on 'Cancel' button then set the values stored in variables in respective cells.
Please let me know if you need any additional details.ahmed salahPosted Jul 25, 2016, 9:44 AM
ahmed salahPosted Jul 24, 2016, 6:35 AM
Amar GaikwadPosted Jul 24, 2016, 12:30 AM