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

ConfirmDialog for the RadGrid

3 Answers 195 Views
Window
This is a migrated thread and some comments may be shown as answers.
adhikari
Top achievements
Rank 1
adhikari asked on 29 Jan 2009, 03:37 AM
Hi,

I have to show radconfirmation dialog before delete operation in radgrid. Also need to display custom message on the confirmation dialog.. 
Like "Are you sure you want to delete product 'ABC' " I have tried to do some code but still not success.

I have tried below code but getting Javascript error "Object expected" in "<linkhref="/WebResource.axd?d=urRCJ9LaDJqEF5aV-iBV2TIs0dSMdI5QLTwDSrfjbfCGWUF2qWm4BeeTnO4BKP0kF2nLj4geiEZ4adWKDh0FWg2&amp;t=633523224580000000"


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="radconfirm.aspx.cs" Inherits="Northwind.Web.ClientModule.radconfirm" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div>
        <asp:Button ID="btnDelete" runat="Server" OnClientClick="return radconfirm('Delete Item?', event);"
            Text="Delete Item" OnClick="btnDelete_Click" />
        <asp:LinkButton ID="linkBtn" runat="Server" OnClientClick="return radconfirm('Delete Item?', event);"
            Text="Delete Item" OnClick="linkBtn_Click" />
        <telerik:radwindowmanager id="RadWindowManager1" runat="server">
            <confirmtemplate>
                {1}      
                <center>
                 <input class="Button" type="button"  style="width:50px" id="dialogYes" value="OK1" onclick="Close()"/>
                <input class="Button" type="button" id="dialogNo" value="No" onclick="javascript:GetRadWindow().ModalDialogCallBack('No');"/>
                 <input class="Button" type="button" style="width:50px" id="dialogCancel" value="Cancel" onclick="javascript:GetRadWindow().close();"/>
                </center>
            </confirmtemplate>
        </telerik:radwindowmanager>
        <asp:Label ID="Label1" runat="server"></asp:Label>

        <script>
            //Replace old radconfirm with a changed version.   
            var oldConfirm = radconfirm;

            window.radconfirm = function(text, mozEvent) {
                alert("1");
                var ev = mozEvent ? mozEvent : window.event; //Moz support requires passing the event argument manually   
                //Cancel the event   
                ev.cancelBubble = true;
                ev.returnValue = false;
                if (ev.stopPropagation) ev.stopPropagation();
                if (ev.preventDefault) ev.preventDefault();

                //Determine who is the caller   
                var callerObj = ev.srcElement ? ev.srcElement : ev.target;

                //Call the original radconfirm and pass it all necessary parameters   
                if (callerObj) {
                    //Show the confirm, then when it is closing, if returned value was true, automatically call the caller's click method again.   
                    var callBackFn = function(arg) {
                        if (arg) {
                            window.setTimeout(function() {
                                callerObj["onclick"] = "";
                                if (callerObj.click) callerObj.click(); //Works fine every time in IE, but does not work for links in Moz   
                                else if (callerObj.tagName == "A") //We assume it is a link button!   
                                {
                                    try {
                                        eval(callerObj.href)
                                    }
                                    catch (e) { }
                                }
                            }, 0);
                        }
                    }
                    oldConfirm(text, callBackFn, 300, 100, null, null);
                }
                return false;
            }  

        </script>

    </div>
    </form>
</body>
</html>


3 Answers, 1 is accepted

Sort by
0
Fiko
Telerik team
answered on 29 Jan 2009, 12:05 PM
Hi Adhikari,

I believe that the following KB article will be of help:
http://www.telerik.com/support/kb/aspnet-ajax/grid/replacing-the-default-confirm-dialog-for-radgrid-with-radwindow-confirm.aspx

Also, you can check the in-built radconfirm functionality in RadGrid:
http://www.telerik.com/help/aspnet-ajax/grdaddingdeleteprompt.html



Sincerely yours,
Fiko
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
adhikari
Top achievements
Rank 1
answered on 30 Jan 2009, 04:00 AM
Hi,

Thanks for the reply. 

I have already done that in my code but I am not getting proper alignment of the button in default radconfirm so I want to customize the UI of the RadConfirm.

Thanks
0
Fiko
Telerik team
answered on 02 Feb 2009, 12:38 PM
Thank you for the feedbdback, Adjikari.

By the way, could you tell me what exactly are the problems with the alignment of the default radconfirm dialog in RadGrid? I might be able to help you as you could change the appearance by overriding the CSS of the dialog. 



Kind regards,
Fiko
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Window
Asked by
adhikari
Top achievements
Rank 1
Answers by
Fiko
Telerik team
adhikari
Top achievements
Rank 1
Share this question
or