RadTreeNodeBinding Question

8 posts, 0 answers
  1. Kevin White
    Kevin White avatar
    60 posts
    Member since:
    Jun 2004

    Posted 10 Feb 2011 Link to this post

    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?
  2. Nikolay Tsenkov
    Admin
    Nikolay Tsenkov avatar
    734 posts

    Posted 16 Feb 2011 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Srujana
    Srujana avatar
    38 posts
    Member since:
    Jan 2011

    Posted 22 Mar 2011 Link to this post

    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.
  5. Kevin White
    Kevin White avatar
    60 posts
    Member since:
    Jun 2004

    Posted 22 Mar 2011 Link to this post

    S.C.,

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

    - Kevin
  6. Srujana
    Srujana avatar
    38 posts
    Member since:
    Jan 2011

    Posted 22 Mar 2011 Link to this post

    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.
  7. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 25 Mar 2011 Link to this post

    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
  8. Ken Hawley
    Ken Hawley avatar
    8 posts
    Member since:
    Apr 2008

    Posted 24 Apr 2014 Link to this post

    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?
  9. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 07 May 2014 Link to this post

    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.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017