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

How to Add radconfirm confirmation when user presses delete key to delete a row in radgrid

3 Answers 285 Views
Grid
This is a migrated thread and some comments may be shown as answers.
muhammad toori
Top achievements
Rank 1
muhammad toori asked on 04 Mar 2010, 02:23 AM
Hi

The users can delete rows in a radgrid by pressing the delete key from the keyboard. But there is no confirmation pop up to prevent the user from deleting the row by mistake. When users presses the delete key i use fireCommand("Cancel", "") to prevent the row from deleting. After that i want to display a radconfirm window but the radconfirm window pops up for a second only and goes away without allowing the user to press either Yes or No. How can I stop the radconfirm window from closing?

case 46: //Delete

                       
            if (!(event.srcElement.type == "text") && !(event.srcElement.type == "textarea")) {
                GetGrid().get_masterTableView().fireCommand("Cancel", "");                    
                radconfirm(prompt, clientCallBackFunc);
            }
            break;

Thanks
Muhammad

3 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 08 Mar 2010, 12:47 PM
Hi,

You should attache a client event handler to the OnKeyPress event of the grid, show the confirmation dialogues and cancel the command if the user chooses "No" as follows:

function keyPressed(sender, args)
{
    args.set_cancel(true);
}

I hope this helps.

Regards,
Tsvetoslav
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.
0
Mohammad
Top achievements
Rank 1
answered on 12 Aug 2015, 05:45 AM

Sir I want to ask a question, 

I have a rad grid and I have to delete a record by pressing delete(keyboard key), I want to show a rad confirm box before delete any record, Problem is that I have to delete this record by server side, when I pressed delete key so first It will show rad confirm box automatically , then go to event, remember that I am pressing delete short cut key from keyboard ,

here is my code

 <ClientSettings EnableRowHoverStyle="true" AllowKeyboardNavigation="true" Selecting-AllowRowSelect="true" ClientEvents-OnKeyPress="keyPress">

Server Side

 if (e.CommandName == RadGrid.DeleteCommandName)
            {

//Perform action to delete record from database

}​

 

0
Maria Ilieva
Telerik team
answered on 12 Aug 2015, 09:42 AM
Hi,

You can use the appraoch below:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
  if (e.Item is GridDataItem)
  {
    ImageButton btn = (e.Item as GridDataItem)["DeleteColumn"].Controls[0] as ImageButton;
    string id= (e.Item as GridDataItem)["ID"].Text;
    btn.OnClientClick = String.Format("if(!confirm('Are you sure you want to delete this record with id: {0}?'))return false;", id);
  }
}


Regards,
Maria Ilieva
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
muhammad toori
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Mohammad
Top achievements
Rank 1
Maria Ilieva
Telerik team
Share this question
or