Delete Confirmation using RadWindow.Confirm().

10 posts, 1 answers
  1. Yonghan
    Yonghan avatar
    27 posts
    Member since:
    Dec 2010

    Posted 09 Jan 2011 Link to this post

    Hi,

    I can't handle delete confirmation using RadWindow.Confirm().
    I think RadWindow.Confirm() is not truly modal.

    I added the delete button column as follows:
    <t:GridViewColumn>
      <t:GridViewColumn.CellTemplate>
        <DataTemplate>
          <t:RadButton Command="t:RadGridViewCommands.Delete" CommandParameter="{Binding}">
            <t:RadButton.Content>
              <Image Source="{StaticResource DelImageSource}" Width="16" Height="16"/>
            </t:RadButton.Content>
          </t:RadButton>
        </DataTemplate>
      </t:GridViewColumn.CellTemplate>
    </t:GridViewColumn>

    and I wait user confirmation at Deleting event handler like this:
    private void selectionGrid_Deleting(object sender, GridViewDeletingEventArgs e)
    {
      RadWindow.Confirm(ApplicationStrings.DeleteConfirmMessage, (s1, e1) =>
      {
        e.Cancel = (a.DialogResult.HasValue && !a.DialogResult.Value);
      });
    }

    but it's not work!
    when confirm windows is poped up, the row was already deleted. so e.Cancel = true is useless.


    but MessageBox.Show() is working.

    private void dataGrid_Deleting(object sender, GridViewDeletingEventArgs e)
    {
      var result = MessageBox.Show(ApplicationStrings.DeleteConfirmMessage, "Confirmation", MessageBoxButton.OKCancel);
      e.Cancel = (result == MessageBoxResult.Cancel);
    }

  2. Answer
    Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 10 Jan 2011 Link to this post

    Hi Yonghan,

    In our online documentation is shown the recommended way to synchronize the RadGridView's Deleting event with RadWindow. Please take a look at the following article "Delete" and let me know how this works for you. In addition to this you may send us a small application via support ticket where we can see what is wrong in your code snippet.

    I will be glad if I can assist you further.

    Greetings,
    Vanya Pavlova
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  3. DevCraft banner
  4. Yonghan
    Yonghan avatar
    27 posts
    Member since:
    Dec 2010

    Posted 10 Jan 2011 Link to this post

    Hi, the article "Delete" is works fine. thanks for the tip.
    But, Do you think is it simple way? In my opinion, it's be more simple like this:

          var result = MessageBox.Show("Are you sure?", "Confirmation", MessageBoxButton.OKCancel);
          e.Cancel = (result == MessageBoxResult.Cancel.);

    Thanks,
  5. towpse
    towpse avatar
    224 posts
    Member since:
    Mar 2008

    Posted 31 Jan 2011 Link to this post

    isn't there a way to replace all regular confirm dialogs with the rad confirm?

    i'm adding a confirm to a template delete column like this

    private void RadGrid1_ItemDataBound(object sender, Telerik.WebControls.GridItemEventArgs e)
    {
      
    if(e.Item is GridDataItem)
      {
       GridDataItem dataItem = e.Item
     as GridDataItem;
       
    string contactName = dataItem["ContactName"].Text;

       LinkButton button = dataItem[
    "DeleteColumn"].Controls[0] as LinkButton;
       button.Attributes[
     "onclick"] = "return confirm('Are you sure you want to delete " +
       contactName +
     "?')";
      }
    }

    how can i replace the confirm with the nicer looking rad window confirm?
  6. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 01 Feb 2011 Link to this post

    Hi,

     I'm not sure how this is related to RadGridView for Silverlight?

    Best wishes,
    Vlad
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  7. towpse
    towpse avatar
    224 posts
    Member since:
    Mar 2008

    Posted 01 Feb 2011 Link to this post

    oops. didn't realize this was a silverlight thread. i landed here from a google search.
  8. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 02 Feb 2011 Link to this post

    Hello Matt,

    This is explained in the third paragraph of this documentation article:
    http://www.telerik.com/help/aspnet-ajax/grdaddingdeleteprompt.html

    Alternatively, you can use the solution presented in the KB article below:
    http://www.telerik.com/support/kb/aspnet-ajax/grid/replacing-the-default-confirm-dialog-for-radgrid-with-radwindow-confirm.aspx

    Greetings,
    Sebastian
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  9. Marc Roussel
    Marc Roussel avatar
    429 posts
    Member since:
    Dec 2009

    Posted 26 Apr 2013 Link to this post

    I'm not quiet sure but it seems there's a flaw in that documentation for the Delete because saying the Deleting is when the user is about to delete but yes Deleting event is all about performing confirmation before deletion however my line is deleted from the UI even before asking the confirmation in the Deleting event so either I'm lost and I'm stupid or there's really something wrong !?
  10. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 29 Apr 2013 Link to this post

    Hi Marc,

     


    Rather unfortunately it is not clear, whether you are referring to the RadGrid for ASP. NET AJAX or RadGridView for Silverlight/WPF. Could you be please more specific? I believe that the best option here is to open a new thread for the corresponding product type and ask your questions there.
    In this way it will be much more easier for our support services to provide you with the desired information. 


    Have a great day! 


    Greetings,
    Vanya Pavlova
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  11. Marc Roussel
    Marc Roussel avatar
    429 posts
    Member since:
    Dec 2009

    Posted 29 Apr 2013 Link to this post

    It's ok I found in another thread that I have to set e.Cancel = tru at the begining and ask the confirmation after.
    It's all god now
Back to Top
DevCraft banner