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; } } });
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:
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
I have enabled the AutoCommit to true. But the functionality is not working as I expected. So I did custom logic i.e. for delete is true then autocommit true. Thank you for your response.
I will get back to you if I get any issue.
Thanks
Indra
I am glad that you find my suggestion helpful.
Thank you for using Infragistics components.