Cancel a Postback depending RadConfirm

2 posts, 1 answers
  1. Laz
    Laz avatar
    31 posts
    Member since:
    Apr 2009

    Posted 31 Aug 2009 Link to this post

    Hi,

    i have a RadToolbar and a RadGrid.

    In the RadGrid i selected Items to delete them. Before i deleting i want to confirm this event by a radConfirm.

    But no matter what i do always the postback is running.

    Here my code:
    <script type="text/javascript">  
     
        var RadGrid1;  
        var RadConfirmState = false;  
     
          
        function GetGridObject(sender, eventArgs) {  
            RadGrid1 = sender;  
        }  
     
          
        function OnClientButtonClicking(sender, args) {  
            var comandName = args.get_item().get_commandName();  
            if (comandName == "Save") {  
                var DataItems = $find("<%=Grid1.ClientID %>").get_masterTableView().get_dataItems();  
                var masterTable = $find('<%= Grid1.ClientID %>').get_masterTableView();  
                for (i = 0; i < DataItems.length; i++) {  
                    var cell = masterTable.getCellByColumnUniqueName(masterTable.get_dataItems()[i], "ckbDelete");  
                    var checkbox = cell.getElementsByTagName("INPUT")[0];  
                    if (checkbox != null) {  
                        if (checkbox.checked == true) {  
                            OpenConfirm();  
                        }  
                    }    
                }  
            }  
            //alert('RadConfirmState: ' + RadConfirmState);  
              
           // CAN NOT CANCEL EVENT  
            args.set_cancel(!RadConfirmState);  
            //return false;  
        }  
     
        function OpenConfirm() {  
            radconfirm('<h3 style=\'color: #333399;\'>Are you sure?</h3>', confirmCallBackFn, 330, 100, null, 'RadConfirm custom title');  
        }  
        function confirmCallBackFn(arg) {  
            radalert("<strong>radconfirm</strong> returned the following result: <h3 style='color: #ff0000;'>" + arg + "</h3>", null, null, "Result");  
            RadConfirmState = arg;  
        }  
     
    </script> 
     
    <table class="style1" cellpadding="0" cellspacing="0">     
        <tr>    
            <td style="width: 100%">     
                <telerik:RadToolBar ID="rtbOne"      
                                    style="display: block; float: none"       
                                    runat="server"      
                                    OnClientButtonClicking="OnClientButtonClicking"    
                                    OnButtonClick="rtbOne_ButtonClick"      
                                    Width="100%">     
                    <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>    
                    <Items>    
                            
                        <telerik:RadToolBarButton runat="server"      
                            ImageUrl="~/Image_01.png"      
                            CommandName="Save" Text="Save"      
                            ToolTip="Save...">     
                        </telerik:RadToolBarButton>                                                
                    </Items>    
                </telerik:RadToolBar>    
            </td>    
         </tr>    
    </table>    
        <telerik:RadGrid ID="Grid1" runat="server" BorderStyle="Solid"      
            AllowMultiRowEdit="True" Width="100%"      
            AutoGenerateColumns="False" onitemdatabound="Grid1_ItemDataBound"      
            OnItemCreated="Grid1_ItemCreated"    
            OnNeedDataSource="Grid1_OnNeedDataSource"      
            oncancelcommand="Grid1_CancelCommand" GridLines="None">     
            <HeaderContextMenu>    
                <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>    
            </HeaderContextMenu>    
            <PagerStyle Mode="NumericPages"></PagerStyle>    
            <ClientSettings allowrowsdragdrop="false" AllowColumnsReorder="false"       
                    ReorderColumnsOnClient="false">     
                    <Selecting AllowRowSelect="True" />    
                    <Scrolling AllowScroll="false" UseStaticHeaders="false" />    
                    <ClientEvents OnGridCreated="GetGridObject"></ClientEvents>    
            </ClientSettings>    
            <MasterTableView EditMode="InPlace" GridLines="Both" BorderStyle="Solid" GroupsDefaultExpanded="true" runat="server">     
                 
                <GroupByExpressions>    
                    <telerik:GridGroupByExpression>    
                        <SelectFields>    
                            <telerik:GridGroupByField      
                                    FieldName="Text_one"      
                                    HeaderText=" "    
                                    HeaderValueSeparator=" ">     
                            </telerik:GridGroupByField>    
                        </SelectFields>       
                        <GroupByFields>    
                            <telerik:GridGroupByField      
                                    FieldName="Text_one"      
                                    SortOrder="Ascending">     
                            </telerik:GridGroupByField>    
                        </GroupByFields>                                       
                    </telerik:GridGroupByExpression>    
                </GroupByExpressions>    
                 
                <Columns>    
                    <telerik:GridEditCommandColumn  UniqueName="editCommand"      
                        HeaderImageUrl="~/Images/Edit.gif"      
                        ButtonType="ImageButton"      
                        CancelImageUrl="~/Images/Cancel.gif"      
                        UpdateImageUrl="~/Images/Save.gif"      
                        EditImageUrl="~/Images/Edit.gif">     
                    <ItemStyle Width="20px"></ItemStyle>    
                    </telerik:GridEditCommandColumn>    
                     
                    <telerik:GridCheckBoxColumn UniqueName="ckbDelete"      
                        HeaderImageUrl="~/Images/Close.gif">     
        
                    <HeaderStyle HorizontalAlign="Center"></HeaderStyle>    
                        <ItemStyle Width="20px" />    
                    </telerik:GridCheckBoxColumn>    
        
                    <telerik:GridBoundColumn DataField="Id" UniqueName="Id"      
                        Visible="false">     
                    </telerik:GridBoundColumn>    
            
                                                            
                    <telerik:GridTemplateColumn HeaderText="Text Group" GroupByExpression="" Groupable="true"    
                        DataField="CT" UniqueName="CT" Visible="false">     
                        <ItemStyle Width="200px"/>     
                        <ItemTemplate>    
                            <asp:Label runat="server" Text='<%# Eval("text") %>'      
                                CssClass=""></asp:Label>    
                        </ItemTemplate>    
                    </telerik:GridTemplateColumn>    
        
                    <telerik:GridTemplateColumn HeaderText="Description" DataField="Temptext"      
                        UniqueName="Temptext">     
                        <ItemTemplate>    
                            <asp:Label runat="server" Text='<%# Eval("Temptext") %>' CssClass=""></asp:Label>    
                        </ItemTemplate>    
                    </telerik:GridTemplateColumn>    
                      
                </Columns>                        
            </MasterTableView>    
            <FilterMenu>    
                <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>    
            </FilterMenu>    
        
        </telerik:RadGrid>    
     

    Thanks
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 01 Sep 2009 Link to this post

    Hi Laz,

     

    I hope the code library which describes how to block execution thread with radconfirm would be of help.

     

    Thanks,

    Princy.

Back to Top