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
355
igGrid CRUD operations
posted

I want to perform CRUD operations in the grid. I want to do individual updates and do not want to commit the grid on client side until the CRUD operations have taken place in the database successfully. So when deleting a row in the grid

 

$('body').on('iggridupdatingrowdeleted', '#grid', function () {

  $('#grid').igGrid("saveChanges")

 if (SuccessfulUpdate)

{

 $('#grid').igGrid("commit");

}

else

{

// Do not commit

}

});

How can I check for successful DB update here?

Parents
  • 17590
    Offline posted

    Hello Anonymous,

    Thank you for posting in our community.

    By design transactions created for CRUD operations are kept locally in the browser. In order to make a POST request and send these changes to the server you will have to commit and call saveChanges method afterwards. This will invoke an AJAX request to the updateUrl option(if set) and pass the serialized transaction log as a part of the POST request. Basically, this means that currently it is not possible to update the data base without committing changes first on the client side.

    In case that error is thrown what I can suggest is handling the error callback of the saveChanges method and data bind igGrid in this handler. For example:

    // Save changes with success and error callbacks
    $(".selector").igGrid("saveChanges", function (data) {
        $("#message").text("Changes were saved successfully").fadeIn(3000).fadeOut(5000);
    },
    function(jqXHR, textStatus, errorThrown) {
        $("#message").text("An error occurred while saving the changes. Error details: " + textStatus).fadeIn(3000).fadeOut(5000);

         $(".selector").igGrid("dataBind");
    });

    I hope you find my information helpful.

    Please let me know if you have any additional questions regarding this matter.

Reply Children