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

Confirm Dialog box.

1 Answer 138 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Yogesh
Top achievements
Rank 1
Yogesh asked on 07 Sep 2012, 05:02 AM
Rad grid has a property called confirm text which is used to pop up a confirm dialog box.
eg.

 

 

<telerik:GridButtonColumn ConfirmText="Delete this Location?" ConfirmDialogType="RadWindow"

 

 

 

ConfirmDialogHeight="25px" ConfirmDialogWidth="250px" ConfirmTitle="Delete" ButtonType="ImageButton"

 

 

 

CommandName="Delete" />

 

Confirm dialog box has two button submit and cancel.
By default when popup open, focus is on submit button. Could you tell me how to change the focus to cancel button.

Thanks
Yogesh.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 07 Sep 2012, 05:45 AM
Hi Yogesh,

By default the OK button is focussed in the browser confirm dialog. Try the following JavaScript to focus the cancel button.
C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
 if (e.Item is GridDataItem)
 {
   GridDataItem item = (GridDataItem)e.Item;
   ImageButton img = (ImageButton)item["ButtonColumn"].Controls[0];
   img.Attributes.Add("onclick", "confirm();return false;");
 }
}
JS:
function confirm() {
        var oConfirm = radconfirm("Delete this Location?"); //gets a reference to the confirm popup
        var elementList = $telerik.$(".rwPopupButton", oConfirm.get_popupElement()); //gets reference to the buttons in the confirm
        setTimeout(function () {
            elementList[1].focus(); //focuses the second button, which is the cancel
        }, 0);
    }

Thanks,
Shinu.
Tags
Grid
Asked by
Yogesh
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or