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

How to create Self Hierarchy In Grid

1 Answer 61 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Majid
Top achievements
Rank 2
Majid asked on 15 Jul 2013, 05:48 AM

Hi,

I want to show parent child hierarchy or self hierarchy but I don't know Levels of Hierarchy.  Next Hierarchy Table should be shown on based of some decision from code. I have seen one example http://www.telerik.com/help/aspnet-ajax/grid-self-referencing-hierarchy.html But It didn't allow any CRUD operations.

I want to do this by Coding and How can I add more GridTableView in Existing GridTableView? Below is Grid Code

<telerik:RadGrid ID="BicCodeGrid" runat="server" AutoGenerateColumns="false" OnNeedDataSource="BicCodeGrid_NeedDataSource"
                    Skin="Silk" OnItemCommand="BicCodeGrid_ItemCommand" OnDetailTableDataBind="BicCodeGrid_DetailTableDataBind"
                    OnItemDataBound="BicCodeGrid_ItemDataBound" >
                    <MasterTableView Width="100%" DataKeyNames="BICCodeID" ClientDataKeyNames="BICCodeID"
                        HorizontalAlign="NotSet" AutoGenerateColumns="False">
                        <Columns>
                            <telerik:GridBoundColumn HeaderText="Kode" DataField="BICCode" UniqueName="BICCode"
                                ReadOnly="true" ItemStyle-Width="50px">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn HeaderText="Område" DataField="DanishDescription" UniqueName="DanishDescription"
                                ReadOnly="true" ItemStyle-Width="400px">
                            </telerik:GridBoundColumn>
                            <telerik:GridButtonColumn ButtonType="PushButton" Text=" + " CommandName="AddBicCode">
                            </telerik:GridButtonColumn>
                        </Columns>
                        <DetailTables>
                            <telerik:GridTableView DataKeyNames="BICCodeID" Name="DetailsTable" Width="100%" on>
                                <ParentTableRelation>
                                    <telerik:GridRelationFields MasterKeyField="BICCodeID" DetailKeyField="ParentID" />
                                </ParentTableRelation>
                                <Columns>
                                    <telerik:GridBoundColumn HeaderText="Kode" DataField="BICCode" UniqueName="BICCode"
                                        ReadOnly="true" ItemStyle-Width="50px">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="Område" DataField="DanishDescription" UniqueName="DanishDescription"
                                        ReadOnly="true" ItemStyle-Width="300px">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridButtonColumn ButtonType="PushButton" Text=" + " CommandName="AddBicCode">
                                    </telerik:GridButtonColumn>
                                </Columns>
                            </telerik:GridTableView>
                        </DetailTables>
                    </MasterTableView>
                    <ClientSettings>
                        <ClientEvents OnCommand="RaiseCommand" />
                    </ClientSettings>
                </telerik:RadGrid>

 

 

 

1 Answer, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 17 Jul 2013, 03:13 PM
Hi Majid,

Instead of using RadGrid with self referencing hierarchy for your scenario, better option would be to use the RadTreeList control which fully covers your requirements and supports CRUD operations as per your needs. See the online demo below for more information on this matter:
http://demos.telerik.com/aspnet-ajax/treelist/examples/overview/defaultcs.aspx

Regards,
Maria Ilieva
Telerik
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 the blog feed now.
Tags
Grid
Asked by
Majid
Top achievements
Rank 2
Answers by
Maria Ilieva
Telerik team
Share this question
or