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

RadGrid - Declarative Relations.

1 Answer 95 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Taras
Top achievements
Rank 1
Taras asked on 18 Jun 2013, 06:03 PM
I've seen example. 
But I can't realize binding hierarchy.
I've one table ID, ParentID (see attached image)
There is my grid.
<MasterTableView DataSourceID="dsMain" DataKeyNames="ID, ParentID" AllowSorting="True" HierarchyLoadMode="ServerBind" GroupLoadMode="Server">
<DetailTables>
<telerik:GridTableView DataSourceID="dsSub" DataKeyNames="ID, ParentID" Width="100%" AutoGenerateColumns="True"  >
 <ParentTableRelation>
  <telerik:GridRelationFields DetailKeyField="ID" MasterKeyField="ID">
  </telerik:GridRelationFields>
</ParentTableRelation>
 </telerik:GridTableView>
                     
</DetailTables>

My object data source

<asp:ObjectDataSource id="dsMain" runat="server" selectmethod="GetRootCategories" deletemethod="DeleteCategory"
      typename="Ascent.Catalog.Model.DataModel.Categories">
     <deleteparameters>
         <asp:Parameter Name="ID" Type="Int32"/>
     </deleteparameters>
 </asp:ObjectDataSource>
  
<asp:ObjectDataSource id="dsSub" runat="server" selectmethod="GetSubCategoriesByParentCategoryId" deletemethod="DeleteCategory"
      typename="Ascent.Catalog.Model.DataModel.Categories">
    <deleteparameters>
              <asp:Parameter Name="ID" Type="Int32"/>
    </deleteparameters>
     
    <SelectParameters>
    <asp:SessionParameter Name="pID" SessionField="ID" Type="Int32"></asp:SessionParameter>
    </SelectParameters>
 
 </asp:ObjectDataSource>

Each time when "GetSubCategoriesByParentCategoryId" is called  ID = 0.

What am i doing wrong?

1 Answer, 1 is accepted

Sort by
0
Accepted
Andrey
Telerik team
answered on 21 Jun 2013, 10:35 AM
Hello,

I am not sure what is the problem you are experiencing. However, looking through your data I see you have self-referencing hierarchy in your code. RadGrid no longer support such kind of functionality but you could RadTreeList control which is designed for that purpose. In this case you will need to pass only one datasource to the control and it will build the hierarchy for you. Check this online demo application which illustrates the usage of the control.

Regards,
Andrey
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
Taras
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or