Using RadConfirm with grid hierarchy

Thread is closed for posting
2 posts, 0 answers
  1. Telerik Admin
    Telerik Admin avatar
    1679 posts
    Member since:
    Oct 2004

    Posted 13 Nov 2007 Link to this post

    Requirements

    RadControls version

    RadGrid 5.0.1
    RadWindow 1.9.1        

    Web.UI version 2007.3.1425
    .NET version

    2.0    

    Visual Studio version

    2005

    programming language

    VB

    browser support

    all browsers supported by RadControls


     
  2. PROJECT DESCRIPTION
    The attached project demonstrates the use of RadWindow, to replace the standard confirm dialog. The confirm is triggered in the client side onclick event, for the inner level of a hierarchy. It contains information for a specific cell on the row. If the user confirms by clicking the "Ok" button, a postback is made, including information for the key value of the GridDataItem.
  • Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 10 Mar 2008 Link to this post

    Hello,

    Attached to this message, is an update of the project, to take advantage of the latest Prometheus versions of the controls.
    Also, below is all the relevant code used:

    .aspx
        <form id="form1" runat="server">  
            <div> 
                <asp:ScriptManager runat="server" ID="ScriptManager1">  
                </asp:ScriptManager> 
                  
                <telerik:RadCodeBlock runat="server">  
                <script type="text/javascript">  
           
                var argument1;  
                function rConfirm(arg1)  
                {      
                var cValue = "Are you sure you want to close item: " + arg1;    
                argument1 = arg1;      
                  
                var conf = radconfirm(cValue, ajaxRequest);             
                  
                }  
                  
                function ajaxRequest(arg)  
                {  
                    if(arg)  
                    {  
                    var AjaxManager = $find("<%=RadAjaxManager1.ClientID %>");             
                    AjaxManager.AjaxRequest();  
                    }  
                }                     
                </script> 
                </telerik:RadCodeBlock> 
       
                <telerik:RadGrid ID="RadGrid1" DataSourceID="AccessDataSource1" runat="server" Width="95%" 
                    AutoGenerateColumns="False" PageSize="3" AllowSorting="True" AllowMultiRowSelection="False" 
                    AllowPaging="True" GridLines="Both" OnPreRender="RadGrid1_PreRender">  
                    <PagerStyle Mode="NumericPages"></PagerStyle> 
                    <ClientSettings AllowExpandCollapse="True">  
                    </ClientSettings> 
                    <MasterTableView DataSourceID="AccessDataSource1" DataKeyNames="CustomerID" AllowMultiColumnSorting="True" 
                        Width="100%">  
                        <DetailTables> 
                            <telerik:GridTableView CssClass="class1" DataKeyNames="OrderID" DataSourceID="AccessDataSource2" 
                                Width="100%">  
                                <ParentTableRelation> 
                                    <telerik:GridRelationFields DetailKeyField="CustomerID" MasterKeyField="CustomerID" /> 
                                </ParentTableRelation> 
                                <Columns> 
                                    <telerik:GridBoundColumn SortExpression="OrderID" HeaderText="OrderID" HeaderButtonType="TextButton" 
                                        DataField="OrderID">  
                                    </telerik:GridBoundColumn> 
                                    <telerik:GridBoundColumn SortExpression="OrderDate" HeaderText="Date Ordered" HeaderButtonType="TextButton" 
                                        DataField="OrderDate">  
                                    </telerik:GridBoundColumn> 
                                    <telerik:GridBoundColumn SortExpression="EmployeeID" HeaderText="EmployeeID" HeaderButtonType="TextButton" 
                                        DataField="EmployeeID">  
                                    </telerik:GridBoundColumn> 
                                    <telerik:GridTemplateColumn UniqueName="TemplateColumn" HeaderText="Custom Action">  
                                        <ItemTemplate> 
                                            <asp:Image ID="Image1" runat="server" ImageUrl="~/Delete.gif" /> 
                                        </ItemTemplate> 
                                    </telerik:GridTemplateColumn> 
                                </Columns> 
                                <SortExpressions> 
                                    <telerik:GridSortExpression FieldName="OrderDate"></telerik:GridSortExpression> 
                                </SortExpressions> 
                            </telerik:GridTableView> 
                        </DetailTables> 
                        <Columns> 
                            <telerik:GridBoundColumn SortExpression="CustomerID" HeaderText="CustomerID" HeaderButtonType="TextButton" 
                                DataField="CustomerID">  
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn SortExpression="ContactName" HeaderText="Contact Name" HeaderButtonType="TextButton" 
                                DataField="ContactName">  
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn SortExpression="CompanyName" HeaderText="Company" HeaderButtonType="TextButton" 
                                DataField="CompanyName">  
                            </telerik:GridBoundColumn> 
                        </Columns> 
                        <SortExpressions> 
                            <telerik:GridSortExpression FieldName="CompanyName"></telerik:GridSortExpression> 
                        </SortExpressions> 
                    </MasterTableView> 
                </telerik:RadGrid> 
                <asp:AccessDataSource ID="AccessDataSource1" DataFile="~/App_Data/Nwind.mdb" SelectCommand="SELECT * FROM Customers" 
                    runat="server"></asp:AccessDataSource> 
                <asp:AccessDataSource ID="AccessDataSource2" DataFile="~/App_Data/Nwind.mdb" SelectCommand="SELECT * FROM Orders Where CustomerID = ?" 
                    runat="server">  
                    <SelectParameters> 
                        <asp:SessionParameter Name="CustomerID" SessionField="CustomerID" Type="string" /> 
                    </SelectParameters> 
                </asp:AccessDataSource> 
                <telerik:RadWindowManager ID="RadWindowManager1" runat="server">  
                </telerik:RadWindowManager> 
                <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
                    <AjaxSettings> 
                        <telerik:AjaxSetting AjaxControlID="RadGrid1">  
                            <UpdatedControls> 
                                <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
                            </UpdatedControls> 
                        </telerik:AjaxSetting> 
                    </AjaxSettings> 
                </telerik:RadAjaxManager> 
            </div> 
        </form> 


    .cs
     
        protected void RadGrid1_PreRender(object sender, EventArgs e)  
        {  
            foreach (GridDataItem outerItem in RadGrid1.MasterTableView.Items)  
            {  
                if (outerItem.ChildItem.NestedTableViews.Length > 0)  
                {  
                    foreach (GridDataItem item in outerItem.ChildItem.NestedTableViews[0].Items)  
                    {  
                        if ((item is GridDataItem && (item.OwnerTableView.DataKeyNames[0] == "OrderID")))  
                        {  
                            string orderID;  
                            GridDataItem dataItem = (GridDataItem)item;  
                            orderID = dataItem["OrderID"].Text;  
                            Image image = (Image)dataItem["TemplateColumn"].FindControl("Image1");  
                            image.Attributes.Add("onclick", "rConfirm('" + orderID + "');");  
                        }  
                    }  
                }  
            }  
     
        } 


    Greetings,
    Yavor
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  • Back to Top