Capture Row Delete Event

6 posts, 0 answers
  1. Dennis Sebenick
    Dennis Sebenick avatar
    14 posts
    Member since:
    Jun 2007

    Posted 08 Jul 2010 Link to this post

    The radgridview that I've setup allows a user to click the delete button to delete a row.  This works well, but I'd like to prompt the user to confirm a delete.  I've tried to see if there is an event to capture the delete and allow a cancel, but it does not appear to exist.  I realize I could use a delete button, but I do not wish to use this.

    Thank you in advance,
       Dennis
  2. Alexander
    Admin
    Alexander avatar
    306 posts

    Posted 14 Jul 2010 Link to this post

    Hello Dennis Sebenick,

    Thank you for your question.

    You can use the RowsChanging event to cancel deleting of a row in RadGridView:

    private void radGridView1_RowsChanging(object sender, GridViewCollectionChangingEventArgs e)
    {
        if (e.Action == NotifyCollectionChangedAction.Remove)
        {
            e.Cancel = true;
        }
    }

    I hope it helps. Please write back if you have further questions.

    Best regards,
    Alexander
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Alex
    Alex avatar
    2 posts
    Member since:
    Jan 2018

    Posted 15 Feb 2018 Link to this post

    The system doesn't like 'NotifyCollectionChangedAction' so I added:

    using System.Collections.Specialized;

    Now it tells me the operand are incompatible:

            private void grdvwPtOfContact_RowsChanging(object sender, GridViewCollectionChangingEventArgs e)
            {
                if (e.Action == NotifyCollectionChangedAction.Remove)
                {
                    e.Cancel = true;
                }
            }

    How do I fix this?

     


  4. Dimitar
    Admin
    Dimitar avatar
    2938 posts

    Posted 16 Feb 2018 Link to this post

    Hello Alex,

    The following snippet shows the full types that you need to use:
    private void RadGridView1_RowsChanging(object sender, Telerik.WinControls.UI.GridViewCollectionChangingEventArgs e)
    {
        if (e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.Remove)
        {
     
        }
    }

    I hope this will be useful. Let me know if you have additional questions.

    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  5. Alex
    Alex avatar
    2 posts
    Member since:
    Jan 2018

    Posted 16 Feb 2018 in reply to Dimitar Link to this post

            private void grdvwResponsParty_RowsChanging(object sender, GridViewCollectionChangingEventArgs e)
            {
                if (Convert.ToInt16(e.Action) == Convert.ToInt16(NotifyCollectionChangedAction.Remove))
                {
                        e.Cancel = true;
                }
            }

    What worked for me was the above

     

     

  6. Dimitar
    Admin
    Dimitar avatar
    2938 posts

    Posted 19 Feb 2018 Link to this post

    Hello Dennis,

    I am glad that you have found a solution for your case. Do not hesitate to contact us if you have other questions.
     
    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top