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

Grid form buttons - need to prevent being clicked twice

4 Answers 375 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joan
Top achievements
Rank 1
Joan asked on 26 May 2014, 07:52 AM
Hello,
When my users click the buttons on the grid forms the form takes a while to close.  I suspect, the users are clicking the button again, or even clicking another button on the form that also closes the form. I'm seeing that they sometimes create duplicate records.  I've tried to disable the button in javascript but the form doesn't close.  It does a postback and comes back with the button enabled.
Is there a way to achieve disabling a few buttons and still have the normal behaviour?

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 27 May 2014, 07:02 AM
Hi Joan,

You can attach a CommandName with that button access it in the ItemCommand event and disable it.

C#:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
   if (e.CommandName == "Commnad Name")
   {
    if (e.Item is GridEditableItem)
      {
        GridEditableItem edit = (GridEditableItem)e.Item;
        Button btn = (Button)edit.FindControl("ButtonID");
        btn.Enabled = false;
      }
   }
}

Thanks,
Princy
0
Joan
Top achievements
Rank 1
answered on 27 May 2014, 07:13 AM
That would be a server side action.  I don't want the buttons permanently disabled.  I want them disabled client side while the postback is taking place until the form is closed which happens on return from the postback. The buttons already have a command name attached. The problem occurs with the insert button, which if clicked a second time causes 2 records to be written.
It's an easy thing to do with normal HTML buttons on a page, but these buttons are on the pop up edit/insert form of a grid.
0
Maria Ilieva
Telerik team
answered on 29 May 2014, 08:41 AM
Hello Joan,

The best approach for your case is to ajaxify the RadGrid control and place modal RadAjaxLoadingPanel. This way the ability for double clicking the button and subsequent request to appear will be eliminated.

I hope this helps.

Regards,
Maria Ilieva
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Joan
Top achievements
Rank 1
answered on 30 May 2014, 03:46 AM
Thanks for your input.  I had it in a loading panel at some stage and there were problems with the way I needed access to other data on the page during the postback. I think I'll just add a label saying "Please wait for the form to close". 
Tags
Grid
Asked by
Joan
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Joan
Top achievements
Rank 1
Maria Ilieva
Telerik team
Share this question
or