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

[Solved] Disable Update button of EditCommandColumn after user click

2 Answers 307 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Syed
Top achievements
Rank 1
Syed asked on 27 Jun 2014, 02:57 AM
Hi All
I have a Radgrid with many records and while updating It create copy of current month records  and put as  new records. I would like to make sure that person could not hit the button twice in one go. otherwise it will create two copies of the current month records. Is it possible I can disable update button after user click it. I am using EditCommandColumn.
Please update me it is urgent.
Thanks in advance
Syed

2 Answers, 1 is accepted

Sort by
0
Syed
Top achievements
Rank 1
answered on 27 Jun 2014, 03:29 AM
It would be good If I disable the button using Jacvascript
0
Viktor Tachev
Telerik team
answered on 01 Jul 2014, 02:02 PM
Hi Syed,

When a row in the RadGrid is placed in EditMode and the Update button is clicked the edit form is closed. This way the UpdateButton could not be pressed twice. However, if you would like to disable the LinkButton that is rendered on the client you could use the following approach. Handle the server-side ItemCreated event for RadGrid and use it to add handler for the ClientClicked event of the button:

ItemCreated handler:

protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
    {
        GridEditFormItem editForm = e.Item as GridEditFormItem;
 
        LinkButton updateButton = editForm.FindControl("UpdateButton") as LinkButton;
        updateButton.OnClientClick = "clientClicked(this, event);";
         
    }
}

The clientClicked function would look similar to the one below:

function clientClicked(sender, args) {
    if (customCondition) {
        args.preventDefault();
    }
     
}

Note that you would need to add logic that defines when the button click should be prevented.


Regards,
Viktor Tachev
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.

 
Tags
Grid
Asked by
Syed
Top achievements
Rank 1
Answers by
Syed
Top achievements
Rank 1
Viktor Tachev
Telerik team
Share this question
or