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

RadTreeNodeBinding Question

7 Answers 141 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Kevin White
Top achievements
Rank 2
Kevin White asked on 10 Feb 2011, 05:22 PM
I have been experimenting with the advanced binding features of the RadTreeView and have hit a wall in my knowledge level. Perhaps one of you can answer it.

I have a simple database schema, as shown in the attached picture.
Manufacturers can have Products which in turn have multiple Parts.

The project contains the Linq to Sql model (also shown)

I am try to have the tree bind the various levels using the RadTreeNodeBinding technique.

<telerik:RadTreeView ID="RadTreeView1" runat="server">
    <DataBindings>
        <telerik:RadTreeNodeBinding Depth="0" TextField="ManufacturerName" ValueField="ManufacturerID" />
        <telerik:RadTreeNodeBinding Depth="1" DataMember="Products" TextField="ProductName" ValueField="ProductID" />
        <telerik:RadTreeNodeBinding Depth="2" DataMember="Parts" TextField="PartName" ValueField="PartName" />
    </DataBindings>
</telerik:RadTreeView>

with code behind

protected void Page_Load(object sender, EventArgs e)
{
    if (!this.IsPostBack)
    {
        DataClasses1DataContext db = new DataClasses1DataContext();
        RadTreeView1.DataSource = db.Manufacturers;
        RadTreeView1.DataBind();
    }
}

Only the root nodes of Manufacturer show up, shouldnt it traverse automatically by setting the "DataMember" property to the Property of the LinqToSql Entity that has children entities?

7 Answers, 1 is accepted

Sort by
0
Nikolay Tsenkov
Telerik team
answered on 16 Feb 2011, 10:06 AM
Hello Kevin,

The problem appears to be that you use n records in order to create n * x * y nodes.
This kind of binding isn't automatically supported.

What I would like to suggest, is to create a temporal relation (either on db or application level) in which you will add all records in the expected by RadTreeView format - id, parentId, text and all the other columns you need for your nodes. All you need to do is add all the records from all the tables in one place (id's will be in the same column, parentId's and Names, too). The column for the id's shouldn't be with unique constraint, because the id's are unique only in their initial positions (not in the temporal table/relation).


Regards,
Nikolay Tsenkov
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Srujana
Top achievements
Rank 1
answered on 22 Mar 2011, 04:35 PM
Hello Kevin,

I was trying to get what you are suggesting in your post, I am working with the treeview that will have 6 levels deep, I am using entity frame work to design the database, my structure is like  Sites->Plants->Routes->Zones->Stops->tasks ,in other words Each Site has multiple Plants, and each Plant has Multiple Routes and so forth. I am trying to bind the data to Treeview in the same order, I am just stuck on how I am going to bind the data. Why do we have to build a temporal relation table, if we already have the relations in Entity framework, could you please share some links that would explain more or some demo or code sample would be great.

And also, I want to do Data load on demand to gain performance, how does it work the solution you mentioned below?

Thanks,
SC.
0
Kevin White
Top achievements
Rank 2
answered on 22 Mar 2011, 04:45 PM
S.C.,

I never got things to work like i wanted so due to time limitations I just built nodes programmatically.

- Kevin
0
Srujana
Top achievements
Rank 1
answered on 22 Mar 2011, 05:37 PM
Thanks for the Response Kevin.

Since we are in the requirments phase, I am trying to find a best way possible to populate the data in to the Treeview.

I would wait for telerik team's feedback/Suggestions as well.

Thanks,
SC.
0
Dimitar Terziev
Telerik team
answered on 25 Mar 2011, 05:56 PM
Hi Srujana,

Generally, if you want your RadTreeView to be expanded on page load, it's better to bind it at server-side.
On the other hand you could use WebService to load the child nodes of a particular node on expand.
You should decide, which will be the most appropriate approach in your scenario.
Please check the demo here, which shows the different Load on Demand modes.

Kind regards,
Dimitar Terziev
the Telerik team
0
Ken Hawley
Top achievements
Rank 1
answered on 24 Apr 2014, 04:58 PM
Your demo page at http://demos.telerik.com/aspnet-ajax/treeview/examples/programming/databindings/defaultcs.aspx
says this:

The DataBindings collection lets you provide different sets of data bindings to the nodes on different levels of the treeview. You can even bind the nodes on each level of the treeview from different tables in a DataSet.This example demonstrates how to use databindings to apply declarative mapping of data fields to treeview node properties.

I can find nowhere that this is documented ... binding to different datamembers in a dataset at each level of the hierarchy.  There does not seem to be anywhere to specify the fieldid and parent id from level to level, only at the top, TreeView, level.  Your hierarchy examples all use one self-referential table.  Are multi-table hierarchies supported and, if so, how are they specified?
0
Dimitar Terziev
Telerik team
answered on 07 May 2014, 10:52 AM
Hello,

With the current implementation of the control the approach described in the description section of the demo is incorrect. One could not bind the control to different tables providing data for different node levels using a DataSet. In order to bind the RadTreeView to multiple tables, one should join the results from the select operations and to merge them to a self referencing table as describe in this help article here. As a token of gratitude for reporting this incorrect information, your Telerik points are updated.

Regards,
Dimitar Terziev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
TreeView
Asked by
Kevin White
Top achievements
Rank 2
Answers by
Nikolay Tsenkov
Telerik team
Srujana
Top achievements
Rank 1
Kevin White
Top achievements
Rank 2
Dimitar Terziev
Telerik team
Ken Hawley
Top achievements
Rank 1
Share this question
or