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

4 posts, 0 answers
  1. muhammad toori
    muhammad toori avatar
    12 posts
    Member since:
    Jan 2010

    Posted 03 Mar 2010 Link to this post

    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

  2. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts

    Posted 08 Mar 2010 Link to this post

    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.
  3. Mohammad
    Mohammad avatar
    1 posts
    Member since:
    Nov 2014

    Posted 12 Aug 2015 Link to this post

    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

    }​

     

  4. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 12 Aug 2015 Link to this post

    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
Back to Top