Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
280
Save changes Issue
posted

Hi,

I have deleted a row and saved to the database. But the grid is not refreshing and same with add as well, please see the image below:

Here is my code for save and delete

$("#saveRow").bind({
click: function (e) {
$("#Grid").igGridUpdating("endEdit", true, true);

$("#Grid").igGrid("saveChanges",
function success() {
$('#txtMessage').css('background-color', 'LightBlue').css('color', 'Gray').css('font-weight', 'bold').css('font-family', 'Courier New');

},
function error(jqXHR, textStatus, errorThrown) {
//alert(JSON.parse(jqXHR.responseText).ErrorMessage);
if (JSON.parse(jqXHR.responseText).ErrorMessage.contains("Success")) {
$('#txtMessage').css('background-color', 'LightBlue').css('color', 'Gray').css('font-weight', 'bold').css('font-family', 'Courier New');
// hide the buttons
$('#saveRow').prop('hidden', true);
$('#cancelRow').prop('hidden', true);

}
else {
$('#txtMessage').css('background-color', 'DarkRed').css('color', 'White').css('font-weight', 'bold').css('font-family', 'Courier New');
}
txtMessage.value = JSON.parse(jqXHR.responseText).ErrorMessage;
});
}

});

$("#deleteRow").igButton({
labelText: $("#deleteRow").val(),
click: function (e) {
var checkstr = confirm('Are you sure you want to delete row(s)?');
if (checkstr === true) {
//check if there is an array to delete all selected wors
if (rowKeys.length > 0) {
$.each(rowKeys, function (ix, el) {
//make sure before delete to clear the selection
$("#Grid").igGridSelection("clearSelection");
$("#Grid").igGridUpdating("deleteRow", el);
$('#saveRow').prop('hidden', false);
$('#cancelRow').prop('hidden', false);
});
} else if (rowKey !== '') {
//check if there is only one row
$("#Grid").igGridSelection("clearSelection");
$("#Grid").igGridUpdating("deleteRow", rowKey);
$('#saveRow').prop('hidden', false);
$('#cancelRow').prop('hidden', false);
} else {
//else there is no selected rows just the button is clicked
alert('No rows selected!');
}
rowKeys = [];
rowKey = '';
}
else {
alert('false');
return false;
}
}
});

Parents
  • 460
    Offline posted

    Hello Indra,

    What I understand from the provided information is that when deleting a row from the grid, the row is correctly deleted from the database itself, but it is not deleted from the grid or rather the grid is not refreshed. From what was written, I understand that this also happens when adding a row, that is, the row is added to the database, but not to the grid itself. Please confirm if I understood it correctly.

    This could be due to several things but with just these provided code snippets I have no way of getting to the source of this behavior. However, what I see on the provided screenshot is that the row is crossed out, I guess the row that is being deleted and this is the behavior of the igGrid's batch editing, that is, after the deletion itself, confirmation is needed to remove the row completely from the grid and the grid to refresh. According to your custom logic, as far as I understand, you want this to commit immediately on deletion, so what I suggest is to set the AutoCommit property of the igGrid to true:

    .ID("grid")
    .AutoCommit(true)

    However, if this does not help you to achieve your requirements, in order to ensure that the described scenario is addressed correctly, I will need some additional information regarding your scenario. Could you please answer the following questions:

    • When deleting, the row is deleted from the database but not from the grid itself and the grid not refreshing?
    • Does the same thing happen when adding a row and what is the behavior there?
    • What other properties do you use? Have you handled some of the delete and add events? Do you have other buttons that perform functions and how do they work?
    • Could you provide more information, screenshots, code snippets or a full code as well as best approach is a sample with steps to reproduce?

    This information is going to be highly appreciated and will help me in my further investigation. Having a working sample on my side, which I can debug, is going to be very helpful in finding the root cause of this behavior.

    Thank you for your cooperation. 

    Regards,

    Georgi Anastasov

    Entry Level Software Developer

    Infragistics

Reply Children