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

RadGrid-MasterTable-DetailTable

1 Answer 93 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Berkant Oral
Top achievements
Rank 1
Berkant Oral asked on 23 Oct 2012, 01:23 PM
Hi everyone. 

I can bind 2 level grid from object datasource. but how can i bind 3 level grid from my object datasource?
My First ObjectDataSource take no parameter,
My second ObjectDatasource take orderId;
I want to my third objectdatasource take orderProductId from 2.level; 
My code is;
telerik:RadGrid ID="radGridOrderProduct" ShowStatusBar="True" DataSourceID="objDsCartProductList"
    runat="server" Width="100%" AutoGenerateColumns="False" AllowSorting="True" AllowPaging="True"
    GridLines="None" CellSpacing="0">
    <PagerStyle Mode="NumericPages"></PagerStyle>
    <MasterTableView Width="100%" DataSourceID="objDsCartProductList" DataKeyNames="Id"
        AllowMultiColumnSorting="True">
        <NestedViewTemplate>
            <asp:Label ID="Label1" Text='<%#Eval("Id") %>' Visible="false" runat="server" />
            <telerik:RadGrid runat="server" ID="radGridOrderProductDetail" DataSourceID="objDsCartProductList"
                GridLines="None">
                <MasterTableView ShowHeader="true" AutoGenerateColumns="False" runat="server" HierarchyLoadMode="ServerOnDemand"
                    DataSourceID="objDsCartProductList">
                    <Columns>
                        <telerik:GridTemplateColumn>
                            <ItemTemplate>
                                <asp:Label ID="lblTotalPrice" runat="server" Font-Bold="true" Font-Size="14px" Text='<%#                (Eval("TotalPrice").ToString()) %>'></asp:Label>
                                <span>TL</span>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                    </Columns>
                </MasterTableView>
            </telerik:RadGrid>
            <asp:ObjectDataSource ID="objDsCartProductList" runat="server" SelectMethod="GetOrderProductListWithOrderId"
                TypeName="MatriksEshop.Web.UserControls.Order.Control.BaseUserControl">
                <SelectParameters>
                    <asp:ControlParameter ControlID="Label1" Name="orderId" PropertyName="Text" Type="String" />
                </SelectParameters>
            </asp:ObjectDataSource>
        </NestedViewTemplate>
        <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
        <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
        </RowIndicatorColumn>
        <ExpandCollapseColumn Visible="True">
        </ExpandCollapseColumn>
        <Columns>
            <telerik:GridTemplateColumn>
                <HeaderTemplate>
                    <asp:Label ID="lblTotalPrices" runat="server" Text="<%$ Resources:Eshop, ProductTotal%>"></asp:Label>
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblTotalPrice" runat="server" Font-Bold="true" Font-Size="14px" Text='<%#(Eval("TotalPrice")) %>'></asp:Label>
                    <span>TL</span>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
        <EditFormSettings>
            <EditColumn FilterControlAltText="Filter EditCommandColumn column">
            </EditColumn>
        </EditFormSettings>
    </MasterTableView>
    <FilterMenu EnableTheming="True">
        <CollapseAnimation Duration="200" Type="OutQuint" />
    </FilterMenu>
</telerik:RadGrid>
<asp:ObjectDataSource ID="objDsCartProductList" runat="server" SelectMethod="GetOrderListWithMemberId"
    TypeName="MatriksEshop.Web.UserControls.Order.Control.BaseUserControl"></asp:ObjectDataSource>

I want to 3.level grid objectDataSource SelectMethod = "GetOrderProductLicenseWithOrderProductId"
Parameter should be radGridOrderProductDetail datakeynames or "Id".
Can u help me for this point?

Best Regards

1 Answer, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 24 Oct 2012, 01:46 PM
Hi Berkant,

I have examined the markup provided and I do not see any relationship between the parent and child tables. If I understand correctly you want a hierarchical RadGrid in the NestedViewTemplate of the parent Grid? If this is not the scenario, please let me know if you are binding the first to the second programmatically?
Both ways in the following code snippet I present a scenario in which the second grid has a child grid related with the orderProductId:
<telerik:RadGrid ID="radGridOrderProduct" ShowStatusBar="True" DataSourceID="objDsCartProductList"
        runat="server" Width="100%" AutoGenerateColumns="False" AllowSorting="True" AllowPaging="True"
        GridLines="None" CellSpacing="0">
        <PagerStyle Mode="NumericPages"></PagerStyle>
        <MasterTableView Width="100%" DataSourceID="objDsCartProductList" DataKeyNames="Id"
            AllowMultiColumnSorting="True">
            <NestedViewTemplate>
                <asp:Label ID="Label1" Text='<%#Eval("Id") %>' Visible="false" runat="server" />
                <telerik:RadGrid runat="server" ID="radGridOrderProductDetail" DataSourceID="objDsCartProductList"
                    GridLines="None">
                    <MasterTableView ShowHeader="true" AutoGenerateColumns="False" runat="server" HierarchyLoadMode="ServerOnDemand"
                        DataSourceID="objDsCartProductList" DataKeyNames="orderProductId">
                        <DetailTables>
                            <telerik:GridTableView DataSourceID="ThirdObjectDataSource">
                                <ParentTableRelation>
                                    <telerik:GridRelationFields DetailKeyField="orderProductId" MasterKeyField="orderProductId">
                                    </telerik:GridRelationFields>
                                </ParentTableRelation>
                                <Columns>
                                    //Your columns
                                </Columns>
                            </telerik:GridTableView>
                        </DetailTables>
                        <Columns>
                            <telerik:GridTemplateColumn>
                                <ItemTemplate>
                                    <asp:Label ID="lblTotalPrice" runat="server" Font-Bold="true" Font-Size="14px" Text='<%#(Eval("TotalPrice").ToString()) %>'></asp:Label>
                                    <span>TL</span>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                        </Columns>
                        orderProductId
                    </MasterTableView>
                </telerik:RadGrid>
                <asp:ObjectDataSource ID="objDsCartProductList" runat="server" SelectMethod="GetOrderProductListWithOrderId"
                    TypeName="MatriksEshop.Web.UserControls.Order.Control.BaseUserControl">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="Label1" Name="orderId" PropertyName="Text" Type="String" />
                    </SelectParameters>
                </asp:ObjectDataSource>
            </NestedViewTemplate>
            <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
            <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
            </RowIndicatorColumn>
            <ExpandCollapseColumn Visible="True">
            </ExpandCollapseColumn>
            <Columns>
                <telerik:GridTemplateColumn>
                    <HeaderTemplate>
                        <asp:Label ID="lblTotalPrices" runat="server" Text="<%$ Resources:Eshop, ProductTotal%>"></asp:Label>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblTotalPrice" runat="server" Font-Bold="true" Font-Size="14px" Text='<%#(Eval("TotalPrice")) %>'></asp:Label>
                        <span>TL</span>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
            <EditFormSettings>
                <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                </EditColumn>
            </EditFormSettings>
        </MasterTableView>
        <FilterMenu EnableTheming="True">
            <CollapseAnimation Duration="200" Type="OutQuint" />
        </FilterMenu>
    </telerik:RadGrid>

Could you please elaborate more on the exact functionality that you want to achieve. Also I suggest that you take a look at the following demo in which a grid with a three level hierarchy is being constructed.

Regards,
Angel Petrov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Berkant Oral
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Share this question
or