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

Radgrid GridTemplateColumn button click show confirmation window with yes/no button

4 Answers 188 Views
Grid
This is a migrated thread and some comments may be shown as answers.
godbrother
Top achievements
Rank 1
godbrother asked on 30 Aug 2013, 08:38 AM
I am using Radgrid Template column button click i show the confirmation.
I need to show yes/no buttion. i using following code.


<ConfirmTemplate>
                <div class="rwDialogPopup radconfirm">
                    <div class="rwDialogText">
                        {1}
                    </div>
                    <div>
                        <a onclick="$find('{0}').close(true);" class="rwPopupButton" href="javascript:void(0);">
                            <span class="rwOuterSpan"><span class="rwInnerSpan">##LOC[Yes]##</span></span></a>
                        <a onclick="$find('{0}').close(false);" class="rwPopupButton" href="javascript:void(0);">
                            <span class="rwOuterSpan"><span class="rwInnerSpan">##LOC[No]##</span></span></a>
                    </div>
                </div>
 </ConfirmTemplate>


and javascript i use

function ConfirmReply(sender, args) {

                var callBackFunction = Function.createDelegate(sender, function(shouldSubmit) {
                    if (shouldSubmit) {
                        this.click();
                    }
                });

                var text = "Do you want to close the message?";
                var ss = radconfirm(text, callBackFunction, 300, 160, null, "Issue Bucket");
args.set_cancel(true);
            }

I get error message

 Object doesn't support property or method 'set_cancel'

 Here:args.set_cancel(true);

if i call outside of grid it is working. Only call from grid template column button getting error.
Please any one help me.

4 Answers, 1 is accepted

Sort by
0
godbrother
Top achievements
Rank 1
answered on 30 Aug 2013, 09:59 AM
No one in telerik. Please help me anyone.

Thanks you in advance.


0
Jayesh Goyani
Top achievements
Rank 2
answered on 30 Aug 2013, 10:28 AM
Hello,

Please try with the below code snippet.

Let me know if i am not understood your question.

<script type="text/javascript">
            function openConfirmPopUp(id) {
                if (parseInt(id) == 1) {
                    return true;
                }
                radconfirm('Client radconfirm: Are you sure?', confirmCallBackFn, 330, 180, null, 'Client RadConfirm', 'test');
                return false;
            }
            function confirmCallBackFn(arg) {
                if (arg) {
                    alert('true');
                }
                else {
                    alert('false');
                }
            }
        </script>
.............
.............
<form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
        <ConfirmTemplate>
            <div class="rwDialogPopup radconfirm">
                <div class="rwDialogText">
                    {1}
                </div>
                <div>
                    <a onclick="$find('{0}').close(true);" class="rwPopupButton" href="javascript:void(0);">
                        <span class="rwOuterSpan"><span class="rwInnerSpan">y_e_s</span></span></a>
                    <a onclick="$find('{0}').close(false);" class="rwPopupButton" href="javascript:void(0);">
                        <span class="rwOuterSpan"><span class="rwInnerSpan">no</span></span></a>
                </div>
            </div>
        </ConfirmTemplate>
    </telerik:RadWindowManager>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="rgAnalysis">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rgAnalysis" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" OnNeedDataSource="RadGrid1_NeedDataSource"
        OnItemDataBound="RadGrid1_ItemDataBound">
        <MasterTableView>
            <Columns>
                <telerik:GridBoundColumn DataField="ID" UniqueName="ID" HeaderText="ID">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Name" UniqueName="Name" HeaderText="Name">
                </telerik:GridBoundColumn>
                <telerik:GridTemplateColumn>
                    <ItemTemplate>
                        <asp:Button ID="Button1" runat="server" OnClientClick='<%# String.Format("return openConfirmPopUp({0});",Eval("ID"))%> ' />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
    </form>


protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
   {
       dynamic data1 = new[] {
             new { ID = 1, Name ="Not open the Radconfirm"},
             new { ID = 2, Name = "Name_2"},
             new { ID = 3, Name = "Name_1"},
             new { ID = 4, Name = "Name_4"},
             new { ID = 5, Name = "Name_1"}
         };
       RadGrid1.DataSource = data1;
   }


Thanks,
Jayesh Goyani
0
godbrother
Top achievements
Rank 1
answered on 02 Sep 2013, 06:14 AM
Thank you sir.
If click on Yes then i want to call server side click event Button1_Click.
If click on No then no need to call any event.

<ItemTemplate>
    <asp:Button ID="Button1" runat="server" OnClientClick='<%# String.Format("return openConfirmPopUp({0});",Eval("ID"))%> '  OnClick="Button1_Click"  />
</ItemTemplate>

0
Jayesh Goyani
Top achievements
Rank 2
answered on 02 Sep 2013, 07:53 AM
Hello,

Please try with the below code snippet.

<form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
        <ConfirmTemplate>
            <div class="rwDialogPopup radconfirm">
                <div class="rwDialogText">
                    {1}
                </div>
                <div>
                    <a onclick="$find('{0}').close(true);" class="rwPopupButton" href="javascript:void(0);">
                        <span class="rwOuterSpan"><span class="rwInnerSpan">y_e_s</span></span></a>
                    <a onclick="$find('{0}').close(false);" class="rwPopupButton" href="javascript:void(0);">
                        <span class="rwOuterSpan"><span class="rwInnerSpan">no</span></span></a>
                </div>
            </div>
        </ConfirmTemplate>
    </telerik:RadWindowManager>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="rgAnalysis">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rgAnalysis" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" OnNeedDataSource="RadGrid1_NeedDataSource"
        OnItemCommand="RadGrid1_ItemCommand">
        <MasterTableView ClientDataKeyNames="ID" DataKeyNames="ID">
            <Columns>
                <telerik:GridBoundColumn DataField="ID" UniqueName="ID" HeaderText="ID">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Name" UniqueName="Name" HeaderText="Name">
                </telerik:GridBoundColumn>
                <telerik:GridTemplateColumn>
                    <ItemTemplate>
                        <asp:Button ID="Button1" runat="server" CommandName="MyCommand" OnClientClick='<%# String.Format("return openConfirmPopUp({0});",Eval("ID"))%> ' />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
    </form>
<telerik:RadCodeBlock ID="telerikodeBlock1" runat="server">
        <script type="text/javascript">
         
 
 
            var ClikedDataKey = null;
            function openConfirmPopUp(id) {
                ClikedDataKey = parseInt(id);
 
                if (parseInt(id) == 1) {
                    return false;
                    confirmCallBackFn(true);
                }
 
 
                radconfirm('Client radconfirm: Are you sure?', confirmCallBackFn, 330, 180, null, 'Client RadConfirm', 'test');
                return false;
            }
            function confirmCallBackFn(arg) {
                if (arg) {
                    var grid = $find("<%=RadGrid1.ClientID %>");
                    if (grid) {
                        var MasterTable = grid.get_masterTableView();
                        MasterTable.fireCommand("MyCommand", ClikedDataKey);
                    }
                }
            }
        </script>
    </telerik:RadCodeBlock>
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    dynamic data1 = new[] {
           new { ID = 1, Name ="Name_1_NoOpenPOPUP"},
           new { ID = 2, Name = "Name_2"},
           new { ID = 3, Name = "Name_3"},
           new { ID = 4, Name = "Name_4"},
           new { ID = 5, Name = "Name_5"}
       };
 
    RadGrid1.DataSource = data1;
}
 
protected void Button1_Click(object sender, EventArgs e)
{
 
}
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == "MyCommand")
    {
        string strKey = e.CommandArgument.ToString();
    }
}


Thanks,
Jayesh Goyani
Tags
Grid
Asked by
godbrother
Top achievements
Rank 1
Answers by
godbrother
Top achievements
Rank 1
Jayesh Goyani
Top achievements
Rank 2
Share this question
or