This is a migrated thread and some comments may be shown as answers.

CancelEdit not working for AddNewDataItem?

1 Answer 114 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 22 Nov 2010, 07:53 PM
I have a complex object model so I need to throw up a separate form to add a new one instead of letting the user edit the rows in-place.  But I still like the idea of offering the "click here to add row" feature.  It's just that when I intercept the OnAddingNewDataItem event I'd like to do this:

        private void OnAddingRow(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
        {
            var editDialog = new MyFormView(null);
            var rowAdded = (bool)editDialog.ShowDialog();

            if (rowAdded)
                GridView.CommitEdit();
            else
                GridView.CancelEdit();
        }

But what happens is even when I Cancel out of the dialog box and call CancelEdit, the grid still shows a newly inserted row (with empty values).  How can I cancel the add that's in progress programmatically?

Update: similar thing happens when I intercept OnDeletingRow so I can throw up a confirmation dialog box - if the user hits Cancel I'd like to cancel the delete, otherwise commit it, but CancelEdit and CommitEdit don't do the trick

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 25 Nov 2010, 03:11 PM
Hello Tim,

You may try to cancel the AddingNewDataItem event of the grid. I am sending you a sample project illustrating one approach accomplishing the desired result.
 

Best wishes,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
Tags
GridView
Asked by
Tim
Top achievements
Rank 1
Answers by
Maya
Telerik team
Share this question
or