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

Confirm Delete Issue.

6 Answers 202 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Phillip Foster
Top achievements
Rank 1
Phillip Foster asked on 18 Aug 2011, 04:15 PM
OK,
I have the following setup on my Page.

Default.aspx contains a UserControl (ProjectGrid.asmx).

ProjectGrid.asmx contains a Grid (with an edit column). the Grid is set to EditForms with a CustomUserControl form (ProjectEditControl.asmx).

ProjectEditControl.asmx contains the custom edit form. with 3 buttons.. (Update / Cancel / Delete).

I want to pop up a confirmation on delete. I've been looking at the RadWindow and have been able to successfully replicate http://demos.telerik.com/aspnet-ajax/button/examples/confirm/defaultcs.aspx. However when trying to apply this same logic to the EditForm Delete. It doesn't error... it just doesn't launch the Window.

Any help would be great. Thank you!


UPDATE
by using the method posted  Here, I was able to get the box to prompt and to call the proper methods. BUT I then had an issue with the EditForm not closing ( I am calling  e.Item.Edit = false;).
I have tested this by removing the confirm dialog using the exact same delete code and it works perfectly (but no confirm box of course).

Upon this I decided to use the standard confirm box.
function StandardConfirm(sender, args) {
         var cancel = !window.confirm("Are you sure you want to delete this project?")
         args.set_cancel(cancel);
      }

However when I do this I get the error:
"Microsoft JScript runtime error: Object doesn't support this property or method" when trying to args.set_cancel.

Obviously I'm missing something.

Please help!


6 Answers, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 23 Aug 2011, 01:23 PM
Hi Phillip,

I am not sure that I understands when exact you want to close the edit form. Do you want to close the form when canceling the delete? Because you have confirmation on the delete button, is that right? Or you have also confirmation on the cancel and update buttons?

If you have confirmation on the cancel button of the edit form, you could fire 'Cancel' Command from MasterTableView of the grid when handling the confirmation CallBack function of the window.

Kind regards,
Vasil
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Phillip Foster
Top achievements
Rank 1
answered on 23 Aug 2011, 06:46 PM
the confirmation is for the "Delete" button.
And the confirmation does pop up.
However after selecting "OK", the editform does not close, it stays open and populates it with the next record in the list. (see attached Screenshots.).
SS1-> Initial Grid
SS2-> Editform shown for project 3
SS3 ->Clicking Delete -> show confirmation
SS4 -> After clicking OK the editform did not collapse, but populated with project 4 data.

thank you!
0
Vasil
Telerik team
answered on 24 Aug 2011, 02:32 PM
Hello Phillip,

You could change the edit mode of the item before deleting it.
protected void RadGrid1_DeleteCommand(object source, GridCommandEventArgs e)
{
        e.Item.Edit = false;
}
Check the attached page for full example.

Best wishes,
Vasil
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Phillip Foster
Top achievements
Rank 1
answered on 24 Aug 2011, 04:00 PM
Vasil,
     Yes, this method works... but on with <asp:Button> in the code you sent me... if you add another button... but a <telerik:RadButton>
<telerik:RadButton ID="radbtnDeleteWithConfirmation" runat="server" OnClientClick="if(!$find('RadGrid1').confirm('Delete this product?', event, 'Delete'))return false;" CommandName="Delete" Text="RadDelete with confirmation"  ></telerik:RadButton>

It will not pop up the confirmation box, it will go directly into the delete command.
0
Phillip Foster
Top achievements
Rank 1
answered on 24 Aug 2011, 05:22 PM
I also have another "random" question on the sample pages you sent to me..
You are using the RadAjaxLoadingPanel on your Grid.
I tried using the same on my Grid and i received the "The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)." error.

I am getting my values using the same method you are... '<%# DataBinder.Eval( Container, "DataItem.id"  ) %>'.
Any ideas?


UPDATE: Ignore this question... I recreate my app as a WebSite instead of a WebApplication. And the Loading panel works just fine.
0
Vasil
Telerik team
answered on 25 Aug 2011, 08:01 AM
Hi Phillip,

Here is an example with telerik:RadButton instead of the asp:Button
  <script type="text/javascript">       
    function DeleteConfirm(sender, args)
    {
      var callBackFunction = Function.createDelegate(sender, function (shouldDelete)
      {
        if (shouldDelete)
        {
          this.click();
        }
      });
 
      var text = "Are you sure you want to Delete the reccord?";
      radconfirm(text, callBackFunction, 300, 100, null, "DeleteConfirm");
      args.set_cancel(true);
 
    }
  </script>
</telerik:RadCodeBlock>
<telerik:RadButton runat="server" OnClientClicking="DeleteConfirm" CommandName="Delete"
  Text="Delete">
</telerik:RadButton>
<telerik:RadWindowManager runat="server">
</telerik:RadWindowManager>

All the best,
Vasil
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
Grid
Asked by
Phillip Foster
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Phillip Foster
Top achievements
Rank 1
Share this question
or