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

How to cancel edit command?

6 Answers 1464 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Holly
Top achievements
Rank 1
Holly asked on 11 Apr 2012, 12:51 AM

Hi!

        I have a question about editing a RadGrid item. We recently bought the AJAX controls, so I’m in the process of converting our old ASP DataGrids and GridViews over to the new RadGrids. A problem I’ve run into is for one of our grids where we don’t want to use the built-in edit row. We have an edit button, but we use a little pop-up that we define in a div below the grid that comes up over the greyed-out page to allow the user to the edit the data. Part of the code we use to populate the pop-up with the data is executed in the code-behind function that executes on the grid’s edit command, so I want to keep the “… Handles RadGrid1.EditCommand” function, but I don’t want the update and cancel buttons to be displayed. I need it to be in edit mode so I can find which row is being edited, but I don’t want it to stay in edit mode because I don’t want the user to have to click two different cancel buttons. I want them to be able to only use our pop-up’s save and cancel buttons. Is there a way that I can do that? I tried to add in some code in the code-behind page to execute when the cancel button is clicked, but I can’t figure out how to cancel the edit command from there. If anyone has any idea how I can cancel the edit command, I would really appreciate it. Thanks!

                Holly

6 Answers, 1 is accepted

Sort by
0
Accepted
Elliott
Top achievements
Rank 2
answered on 11 Apr 2012, 03:37 PM
is it possible to wire the popup to the RadGrid as a popup?

and getting rid of the Cancel / Update is easy - make the edit popup a FormTemplate or use a UserControl and just simply leave out the buttons

as for how to close the Edit-
geItem.Edit = false;
rgEditOrder.MasterTableView.Rebind();

where geItem is the e.Item cast as a GridEditableItem

0
Holly
Top achievements
Rank 1
answered on 19 Apr 2012, 02:32 PM

Dear Marianne,

            Sorry it took so long to reply back. Thank you so much! Closing the edit worked like a charm! I can just execute that in the on-edit code, so the update and cancel buttons will never get a chance to show. Thanks so much for all of your help! Have a nice day!

                        Holly

0
Eva
Top achievements
Rank 1
answered on 17 Feb 2014, 11:43 AM
Hi!
this solution does not work for me.
i have a radgrid with inplace edit mode. i have also a radgrideditcommandcolumn.
when edit command fires then i search for an item . If this item has a certain value i want to cancel the edit command.
i tried your solution above but although i get the message i want edit command is not canceled.
i want to mention that my radgrid works with advanced data binding (needdatasource)
My code is below:

Private Sub RadGrid1_ItemCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand
If e.CommandName = "Edit" Then
Dim item As GridEditableItem = e.Item
Select Case (item("Myitem").Text)
Case "E", "C", "Z", "O", "D"
lbl_message.Text = " . Action Type: " & item("Myitem").Text
item.Edit = False
RadGrid1.MasterTableView.Rebind()
Exit Sub
Case "N", "M", "V"
Case Else
lbl_message.Text = " Action Type ."
item.Edit = False
RadGrid1.Rebind()
Exit Sub
End Select
End If
Exit Sub
0
Princy
Top achievements
Rank 2
answered on 17 Feb 2014, 12:24 PM
Hi Eva,

Please try the following code snippet to cancel edit:

VB:
Protected Sub RadGrid1_ItemCommand(sender As Object, e As GridCommandEventArgs)
    If e.CommandName = RadGrid.EditCommandName Then
        Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
        'Your switch case goes here
        'Example condition with if
        If item("MyItem").Text = "Some Value" Then
            e.Canceled = True           
        End If
    End If
End Sub

Thanks,
Princy
0
Eva
Top achievements
Rank 1
answered on 17 Feb 2014, 12:26 PM
Hi,
Thanks for your help that did work.!!!
0
Rajesh
Top achievements
Rank 1
answered on 09 Mar 2017, 01:04 PM

Hi Princy,

Can you tell me how to close RadWizard on cancel button click. Actually I am calling this inside Radgrid which is located in other page. On cancel click I am not able to close RadWizard. I am new in Telerik control please help me.

Tags
Grid
Asked by
Holly
Top achievements
Rank 1
Answers by
Elliott
Top achievements
Rank 2
Holly
Top achievements
Rank 1
Eva
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Rajesh
Top achievements
Rank 1
Share this question
or