Hierarchical Data Binding

2 posts, 0 answers
  1. Brian
    Brian avatar
    3 posts
    Member since:
    Mar 2009

    Posted 12 Feb 2012 Link to this post

    I have a fairly simple object model:

    public class Location
               public string Name { getset; }

            readonly List<Location> _locations = new List<Location>();
            public List<Location> Locations
                get { return _locations; }
            readonly List<Printer> _printers = new List<Printer>();
            public List<Printer> Printers
                get { return _printers; }
    public class Printer
            public string Name { get; set; }
            public string Mapping { get; set; }
            public string AdditionalInfo { get; set; }
            public string Guid { get; set; }

    So a location can have any number of sub-locations,  and each location can have any number of printers.

    I'd like to bind this to a RadTreeView, such that the 'Name' property of the location/printer is shown 



    The object model is loaded from xml at the moment,  a sample of which can be seen here:

      <Location Name="Basingstoke">
        <Location Name="Development Office">
          <Printer Name="HPPSC950" Mapping="\\DEVPRT002\HPPSC950" Guid="064ceeef-7495-4ac2-8ba4-eb5b1c546a1b"/>
          <Printer Name="LaserJet" Mapping="\\DEVPRT002\LaserJet" Guid="65b0c6be-f251-4100-81c9-eb7535df1371"/>
        <Location Name="Accounts Department">
          <Printer Name="Payroll Printer" Mapping="\\ACCPRT005\XPrinter999" Guid="7eea423a-ac97-4245-9c4d-850d559b3ff9"/>
          <Printer Name="XPrint12346576" Mapping="\\ACCPRT005\XPrint12346576" Guid="7a19adf2-654a-4732-8f35-c168bb7f92f9"/>
          <Printer Name="XPrint00650" Mapping="\\ACCPRT005\XPrint00650" Guid="fa4f1367-f18d-4459-82ae-ac78e6d2ba5e"/>
        <Location Name="Sales Office">
          <Printer Name="Colour LaserJet" Mapping="\\SALPRT001\ColLaser" Guid="b1395465-72b7-42d6-ad26-078600a7a8f8"/>
          <Printer Name="HP6732/2344" Mapping="\\SALPRT001\HP6732" Guid="a0b6cd21-42f0-435a-8870-30107472b041"/>
        <Location Name="HR Department">
          <Printer Name="OKI452224/332/2C" Mapping="\\HR001\Oki" Guid="af4da720-6ccf-4f37-8b9e-e996b71d6e3b"/>
      <Location Name="Dagenham"/>
      <Location Name="Glasgow">
        <Location Name="Main Office">
          <Printer Name="MO32423/2" Mapping="\\GLASP001\MO2" Guid="f48b97e9-abea-43cb-887b-c7b3dc164154"/>
          <Printer Name="MO23432/3" Mapping="\\GLASP001\MO3" Guid="a4c50255-39ac-4c86-beb6-abe90096caf2"/>
      <Location Name="London Southbank">
        <Location Name="1st Floor">
          <Printer Name="XPrinter178" Mapping="\\SALPRT001\XPrinter178" AdditionalInfo="This is an A3 Colour Printer, with 2 paper trays" Guid="95829976-6363-4a46-8a8c-0c3655344913"/>
          <Printer Name="XPrinter192" Mapping="\\SALPRT001\XPrinter192" Guid="51c4a69c-5941-401a-b14f-3d215f077642"/>
          <Printer Name="XPrinter193" Mapping="\\SALPRT001\XPrinter193" Guid="0fd5a42c-5c2a-4fd1-8f8a-91ad17e70725"/>
          <Printer Name="XPrinter145" Mapping="\\SALPRT001\XPrinter145" Guid="0da3f62c-929a-4bb8-9a4e-a7c9795360a8"/>
          <Printer Name="XPrinter156" Mapping="\\SALPRT001\XPrinter156" Guid="1271c159-8715-4a6d-afe3-e773cdbae94d"/>
        <Location Name="2nd Floor">
          <Printer Name="XPrinter198" Mapping="\\SALPRT004\XPrinter198" Guid="6364d0a7-d98e-460b-907a-b591b931fc46"/>
        <Location Name="3rd Floor">
          <Printer Name="XPrinter218" Mapping="\\SALPRT003\XPrinter218" Guid="cdc3013b-172b-4ceb-b6bb-f9279963a3e4"/>
          <Printer Name="XPrinter219" Mapping="\\SALPRT003\XPrinter219" Guid="13606f67-3263-41bc-8b1b-d1a99423f5e5"/>
      <Location Name="London Central">
        <Location Name="Accounts">
          <Printer Name="FG23453" Mapping="\\LONACC\FG23453" Guid="b8b299f6-627a-41e7-949f-ce483e760382"/>
          <Printer Name="YM3443533" Mapping="\\LONACC\YM3443533" Guid="0d3de23e-ae86-4cdc-8461-11c01413bea2"/>
        <Location Name="Sales">
          <Printer Name="Colour Laser" Mapping="\\LONACC\XYX13434" Guid="bdd7f360-255c-42d2-ac58-5e92aa364e0a"/>

    Can this be done with RadTreeView ???

  2. Julian Benkov
    Julian Benkov avatar
    1135 posts

    Posted 15 Feb 2012 Link to this post

    Hi Brian,

    The RadTreeView binding functionality does not support this scenario. You can use load-on-demand Nodes loading and Tag property to implement this case. More information about load-on-demand loading you can find in our online documentation.

    I hope this information is useful. Let me know if you need further assistance. 

    Julian Benkov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Back to Top