This article demonstrates how to bind RadTreeView to RadClientDataSource.
Since Q2 2014RadTreeView can be bound to a RadClientDataSource control. An important aspect of binding to the RadClientDataSource is that the RadTreeViewDataText and DataValue, DataFieldID, DataFieldParentID and DataNavigateUrlField fields should be associated with the custom object properties. Thus you can choose which property value to be shown as RadTreeView item text and value. For reference at the bottom of the web service implementation below you will find the custom class and its properties declaration.
The code snippet below shows sample configuration of RadTreeView bound to RadClientDataSource. The peculiarity of such scenario comes from the fact that the RadTreeView represents hierarchical data. Considering that fact we expect such type of data to be returned by the service to the RadClientDataSource.
Initially the RadTreeView control requests only the root items data from the RadClientDataSource. In the example below it will check for all items data that have ParentID property value to null.
[OperationContract]publicSelfReferencingData[]LoadCustomSelfReferencingData(){var list =newList<SelfReferencingData>();
list.Add(newSelfReferencingData(){ Name ="Cars", Value ="11", ParentID =null, ID ="1"});
list.Add(newSelfReferencingData(){ Name ="Ford", Value ="22", ParentID ="1", ID ="2"});
list.Add(newSelfReferencingData(){ Name ="Mustang 1", Value ="33", ParentID ="2", ID ="3"});
list.Add(newSelfReferencingData(){ Name ="Mustang 2", Value ="44", ParentID ="2", ID ="4"});
list.Add(newSelfReferencingData(){ Name ="Bikes", Value ="55", ParentID =null, ID ="5"});
list.Add(newSelfReferencingData(){ Name ="Cross", Value ="66", ParentID ="5", ID ="6"});
list.Add(newSelfReferencingData(){ Name ="Mon 1", Value ="77", ParentID ="6", ID ="7"});
list.Add(newSelfReferencingData(){ Name ="Mon 2", Value ="88", ParentID ="6", ID ="8"});return list.ToArray();}publicclassSelfReferencingData{publicstring Name {get;set;}publicstring Value {get;set;}publicstring ID {get;set;}publicstring ParentID {get;set;}//public string NavigateURL { get; set; }}