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
1185
Notifying user of Row Delete or delete cancel
posted

I have a webdatagrid where I am able to delete rows without any problem. I have also got the server side RowDeleting event working,which does a dependency check, and cancels the delete if its not permitted. However I'd like to notify the user that this happened - but because the event is asynchronous, I can't update anything else on the page to set a message??

Have you a suggestion as to how I can either:

- somehow pass back a message to the client and display it during the sync call or

- handle the entire thing from the client, including calling an OnDeleting method and acting on its reply (allowed or not allowed) - and thus displaying message using Confirm()/Alert()...etc.

Parents
No Data
Reply
  • 33839
    Verified Answer
    posted

    Hi,

    In your server side rows deleting event, when you cancel the delete on a row, I would suggest setting some sort of error message by setting e.Row.Tag.  Next, you will want to handle the client side RowDeleted event off of the grid's editing core.  You can then access the canceled rows' ids.  From those, you can get the row objects, and then access the tag that you set in the server side event.  Code similar to this would work.  You could throw an alert with the message or update some other element in the DOM.

    function rowsDeleted(sender, e) {
                var grid = ig_controls["WebDataGrid1"];
                var textBox = document.getElementById("ErrorMessage");
                var rowCount = e.get_canceled_rowIDPairs().length;
                for (var i = 0; i < rowCount; i++) {
                    var newMessage = grid.get_rows().get_rowFromIDPair(e.get_canceled_rowIDPairs()[i]).get_tag();
                    message = message + newMessage + "\n";
                }
                textBox.value = message;
            }

    Hopefully this gets you rolling in the correct direction.

    regards,
    David Young

Children