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

Help on Hierarchical grid

1 Answer 73 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Pramod
Top achievements
Rank 1
Pramod asked on 04 Apr 2011, 09:48 PM

Hi,

I have a telrik grid which shows Hierarchical data in telrik grid. I want to populate one more grid(gridTeamMembers) in code below when user selects a row from detailtables ie groupID. I have problem selecting the groupID of Hierarchical  grid which I want to pass to the 3rd grid(gridTeamMembers). I want to use this groupID in SqlDataSource3 to populate the gridTeamMembers grid.

Please help. Here is my code.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
   <script type="text/javascript">
     //<![CDATA[
    

       var grid;

       function GridCreated() {
           grid = this;
       }

     
     
          //]]>
        </script>
       
   
</head>
<body>
    <form runat="server" id="mainForm" method="post">
      
     <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
        <!-- content start -->
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>

        <telerik:RadSplitter ID="RadSplitter1" Width="700px" runat="server" Orientation="Vertical">
            <telerik:RadPane ID="gridPane" runat="server" Height="307px"
                Scrolling="None">
               

        <telerik:RadGrid ID="RadGrid1" OnPreRender="RadGrid1_PreRender" ShowStatusBar="true" DataSourceID="SqlDataSource1"
            runat="server" AutoGenerateColumns="False" PageSize="7" AllowSorting="True" AllowMultiRowSelection="true"
            AllowPaging="True" GridLines="None">
            <PagerStyle Mode="NumericPages"></PagerStyle>
          
            <MasterTableView DataSourceID="SqlDataSource1" DataKeyNames="MainGroupID" AllowMultiColumnSorting="True">
          
                <DetailTables>
                    <telerik:GridTableView DataKeyNames="GroupID" DataSourceID="SqlDataSource2" Width="100%"
                        runat="server">
                      
                        <ParentTableRelation>
                            <telerik:GridRelationFields DetailKeyField="MainGroupID" MasterKeyField="MainGroupID" />
                        </ParentTableRelation>
                       
                        <Columns>
                            <telerik:GridTemplateColumn UniqueName="GroupID" DataField="GroupID">
                                <ItemTemplate>
                                    <asp:Label ID="Label1" Font-Bold="true" Font-Italic="true" Text='<%# Eval("GroupID") %>' Visible="false" runat="server" />
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridBoundColumn SortExpression="GroupID" HeaderText="GroupID" HeaderButtonType="TextButton"
                                DataField="GroupID" UniqueName="GroupID">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn SortExpression="GroupName" HeaderText="Group Name" HeaderButtonType="TextButton"
                                DataField="GroupName" UniqueName="GroupName">
                            </telerik:GridBoundColumn>                           
                        </Columns>
                        <SortExpressions>
                            <telerik:GridSortExpression FieldName="GroupName"></telerik:GridSortExpression>
                        </SortExpressions>
                      
                    </telerik:GridTableView>
                </DetailTables>
                <Columns>
                   
                    <telerik:GridBoundColumn SortExpression="MainGroupID" HeaderText="MainGroupID" HeaderButtonType="TextButton"
                        DataField="MainGroupID" UniqueName="MainGroupID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn SortExpression="MainGroupName" HeaderText="MainGroup Name" HeaderButtonType="TextButton"
                        DataField="MainGroupName" UniqueName="MainGroupName">
                    </telerik:GridBoundColumn>
                   
                </Columns>
                <SortExpressions>
                    <telerik:GridSortExpression FieldName="MainGroupName"></telerik:GridSortExpression>
                </SortExpressions>
                
            </MasterTableView>
            <ClientSettings EnablePostBackOnRowClick="true">
                            <Selecting AllowRowSelect="True" />
                        </ClientSettings>
        </telerik:RadGrid>

         </telerik:RadPane>
            <telerik:RadSplitBar CollapseMode="Both" ID="RadSplitBar2" runat="server" EnableResize="True">
            </telerik:RadSplitBar>
            <telerik:RadPane ID="listBoxPane" runat="server" CssClass="TextStyle" BackColor="#d9eeff">
               
                   <div id="divTeamMembers" style="height:260px;overflow-y:auto;padding:10px 10px 10px 10px; margin:10px 10px 10px 10px;">
                          <telerik:RadGrid ID="gridTeamMembers" runat="server"
                            DataSourceID="SqlDataSource3" Skin="Office2007"                            
                            AllowSorting="true" AllowPaging="false" AllowFilteringByColumn="false"
                            AutoGenerateColumns="false" ShowStatusBar="true" AllowMultiRowSelection="True"
                            Width="99%"
                            >
                                                   
                          
                           <MasterTableView Width="100%" DataKeyNames="MemID"
                                CommandItemDisplay="Top"    DataSourceID="dsTeamMemberInfo"
                                HorizontalAlign="NotSet"
                                AutoGenerateColumns="False"
                                AllowAutomaticUpdates="False"
                                AllowAutomaticInserts="False"
                                AllowAutomaticDeletes="False"
                                EditMode="PopUp">

                           

                            <Columns>
                              
                                <telerik:GridBoundColumn UniqueName="FirstName" DataField="FirstName" HeaderText="First Name" SortExpression="FirstName" AllowFiltering="false" ItemStyle-HorizontalAlign="Left" />
                                <telerik:GridBoundColumn UniqueName="LastName" DataField="LastName" HeaderText="Last Name" SortExpression="LastName" AllowFiltering="false" ItemStyle-HorizontalAlign="Left" />
                              
                            </Columns>
                        </MasterTableView>
                        <ClientSettings EnableRowHoverStyle="true">
                            <Selecting AllowRowSelect="True" />
                             <ClientEvents OnGridCreated="GridCreated"></ClientEvents>                                                         
                        </ClientSettings>                                                           
                        </telerik:RadGrid>
                        </div>
                
            </telerik:RadPane>
        </telerik:RadSplitter>

        <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:testConnectionString %>"
            ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM TestGroups"
            runat="server"></asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource2" ConnectionString="<%$ ConnectionStrings:testConnectionString %>"
            ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM TestGroups1 Where MainGroupID = @MainGroupID"
            runat="server">
            <SelectParameters>
                <asp:Parameter Name="MainGroupID" Type="string" />
            </SelectParameters>
        </asp:SqlDataSource>
       
        <!-- content end -->

        <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
        ConnectionString="<%$ ConnectionStrings:EIProfileConnectionString %>"
        SelectCommand="GetMemberDetail" SelectCommandType="StoredProcedure">
         <SelectParameters>
            <asp:ControlParameter ControlId="Radgrid1" Name="GroupID" PropertyName="SelectedValue" Type="Int32"/>
        </SelectParameters>
    </asp:SqlDataSource>
     
    </form>

</body>
</html>

1 Answer, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 07 Apr 2011, 02:47 PM
Hello Pramod,

Can you try debugging the SqlDataSource3 Selecting event and see if there the select parameter has the proper value? If yes, try modifying the ajax settings as below and see if it makes any difference:

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    <AjaxSettings>
         <telerik:AjaxSetting AjaxControlID="RadGrid1">
             <UpdatedControls>
                 <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                <telerik:AjaxUpdatedControl ControlID="gridTeamMembers" />
             </UpdatedControls>
         </telerik:AjaxSetting>
     </AjaxSettings>
</telerik:RadAjaxManager>


Regards,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Pramod
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question
or