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

By default bind values to DetailedTable

3 Answers 52 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Saravanan
Top achievements
Rank 1
Saravanan asked on 19 Nov 2012, 10:12 AM
This is my requirement,

I have a radgrid - that shows project names
I have a detailed table - that shows project details

So by default i want to expand all the projects and bind the project details to detailed table. The DataSource value for detailed table will be from SQL. 

Please give me a link for similar sample. Or tell me some idea. 

Right now, i tried to expand the node by default in prerender method. But the detailed table's datasource is coming from the Grid i.e. the project names is displayed in detailed table also. 

Any Suggestion?

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Nov 2012, 05:33 AM
Hi,

I suppose you want to show the DetailTable expanded by default. Try setting the MasterTableView property HierarchyDefaultExpanded to true.

ASPX:
<MasterTableView HierarchyDefaultExpanded="true">

Thanks,
Shinu.
0
Saravanan
Top achievements
Rank 1
answered on 21 Nov 2012, 05:37 AM
Thanks for your reply. But if i set  MasterTableViewHierarchyDefaultExpanded="true", the parent table's datasource is assigned to detailed table also.

I want to assign an unique SQL Table for each detailed table. Is there any option for that, or in which event we can do it. Any existing sample or thread will be great help.
0
Shinu
Top achievements
Rank 2
answered on 22 Nov 2012, 04:28 AM
Hi Saravanan,

Please take a look into the sample code snippet I tried.

ASPX:
<telerik:RadGrid ID="RadGrid1" ShowFooter="true" DataSourceID="SqlDataSource1" runat="server">
    <MasterTableView DataSourceID="SqlDataSource1" DataKeyNames="CustomerID" AutoGenerateColumns="false"
        HierarchyDefaultExpanded="true" Name="first">
        <Columns>
            <telerik:GridBoundColumn SortExpression="CustomerID" HeaderText="CustomerID" DataField="CustomerID">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn SortExpression="ContactName" HeaderText="ContactName" DataField="ContactName">
            </telerik:GridBoundColumn>
        </Columns>
        <DetailTables>
            <telerik:GridTableView AutoGenerateColumns="false" Name="Second" DataSourceID="SqlDataSource2">
                <ParentTableRelation>
                    <telerik:GridRelationFields DetailKeyField="CustomerID" MasterKeyField="CustomerID">
                    </telerik:GridRelationFields>
                </ParentTableRelation>
                <Columns>
                    <telerik:GridBoundColumn SortExpression="OrderID" UniqueName="Order" HeaderText="OrderID"
                        DataField="OrderID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn SortExpression="ShipName" HeaderText="ShipName" DataField="ShipName">
                    </telerik:GridBoundColumn>
                </Columns>
            </telerik:GridTableView>
        </DetailTables>
    </MasterTableView>
</telerik:RadGrid>
<asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString3 %>"
    ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM Customers"
    runat="server"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource2" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString3 %>"
    ProviderName="System.Data.SqlClient" SelectCommand="SELECT top 10 * from Orders Where CustomerID = @CustomerID"
    runat="server">
    <SelectParameters>
        <asp:Parameter Name="CustomerID" Type="string"></asp:Parameter>
    </SelectParameters>
</asp:SqlDataSource>

Thanks,
Shinu.
Tags
Grid
Asked by
Saravanan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Saravanan
Top achievements
Rank 1
Share this question
or