Binding to list of objects containing 2 lists

3 posts, 0 answers
  1. Richard
    Richard avatar
    9 posts
    Member since:
    Jun 2009

    Posted 12 Jan 2012 Link to this post

    Hello all,

    Scenario:
    I am using the latest Radcontrols for Winforms (2011.3.11.1116) and I have a list of classes(categories) comprised of the following:
    Name (string)
    SubCats (List of objects(1) - each with props (Name, list of Reports))
    Reports (List of objects(1) - each with props (list of Reports)) 

    Reports is made up of Name and ID

    Is it possible to use something like:
    .Displaymember = "Name\Name\Name\Name"
    .ChildMemeber = "categories\Reports\SubCats\Reports

    or am I forced to loop through my class and populate the nodes manually?

    Any help is appreciated.
  2. Richard
    Richard avatar
    9 posts
    Member since:
    Jun 2009

    Posted 12 Jan 2012 Link to this post

    Update: 

    I finally just looped through the lists and programmatically built the node list for the tree. 

    I'm still looking forward to hearing if there is another approach to binding to this type of data source.

    Thanks in advance.

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 17 Jan 2012 Link to this post

    Hello Richard,

    You can not present the desired structure using object-relational binding mode. The issue is that the Reports object from the second level does not contain SubCats in its properties. You can present the structure with SubCats at the second level following your description of objects:

    .DisplayMember = "Name\Name\Name"
    .ChildMember = "categories\SubCats\Reports"

    The solution in your case is to loop through the lists and programmatically build the nodes.

    I hoe this helps. Let me know if you need further assistance.

    Kind regards,
    Julian Benkov
    the Telerik team

    SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

Back to Top