I did a bit of reading about ErrorTemplates and things related to WebDataGrids. I am able to write the error message to the ErrorTemplate and throw exceptions and to get the exception (as a whole) to the JavaScript dialog, but the desired state would be something like this:
1) Client deletes a row by clicking delete key.
2) We catch RowsDeleting event and some checks for the rows being deleted.
3) If rows should not be deleted, we cancel the delete event and notify the user about this.
The notification part seems to be quite hidden somewhere in the bowels of the WebDataGrid. How can I access it and implement step three?
protected void WebDataGrid1_RowsDeleting(object sender, Infragistics.Web.UI.GridControls.RowDeletingEventArgs e) {
{
if (e.Row.Items[i].Column.Key == "something") {
if (e.Row.Items[i].Value.ToString().Equals("else"))
e.Cancel = true;
// SHOW ERROR FOR THE USER!
...
Hi AriV,
The ErrorTemplate is actually meant to catch exceptions in the grid code or your event handlers so that the error template shows (when the grid is EnableAjax="false") instead of crashing the whole page. What you need to do is to handle the rowsDeleted client side event on the editing core. Off of the event args, there is a method to get an array of cancelled row id pairs. You could take this information and display it to the user on the client. Or if you do the delete on a full postback, you could modify some label or something in the row deleting server event.
regards,David Young
I am getting somewhere here by using the client side events. When the RowDeleting event gets triggered on server side I can catch the cancel in RowDeleted event on client side. However, when I try to do the same in RowUpdating or RowAdding, first the client side RowUpdating triggers. Because we don't have anything from server we cannot do any checks here. Then the server RowUpdating triggers where I say e.Cancel = true; That's the end of the story. No more events anywhere.
How should I deal with the matter?
I have the client side events defined and the functions are in place with debugger; and alert('foo'); so the events wouldn't slip past me. The server side events have breakpoints and e.Cancel = true; and I can see them execute.
Hello AriV,
When you cancel the “RowUpdating” event the updating process is canceled and the changes made were not sent to the Datasource. This means that the old values are returned to the grid - http://help.infragistics.com/Help/NetAdvantage/ASPNET/2010.3/CLR4.0/html/Infragistics4.Web.v10.3~Infragistics.Web.UI.GridControls.WebDataGrid~RowUpdating_EV.html
Can you tell me what version and build number of our controls do you use and what is the Internet browser that you use for testing?
I am waiting for your response.
I am using Infragistics4.Web.v10.3 10.3.20103.2134. I use mainly IE8 and Chrome for testing.
So what you are saying is that when I cancel the updating or inserting event I cannot catch the cancel event on client side? If I want to do some rule checking (for example: a row with identical value in column x exists) and notify the client about this... the only way to do is to make the checking on client side in the first place? What is the preferred way? To make a web service call?
You can cancel the row updating event on the server side and call RegisterClientScriptBlock() method to display a notification on the client. For row updating are you enabling AJAX on the grid for this scenario?
Let me know if you have any questions with this matter. Thank you.
Well, in the end I managed to do everything by using CustomAJAXResponse...