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

Binding to a object with checked state being updated.

3 Answers 68 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Leonard
Top achievements
Rank 1
Leonard asked on 05 Aug 2016, 02:54 PM
I have the following class and not sure how to return the checked state when data binding to Treeview control is being done. Any suggestions would greatly be appreciated.

 

Leonard

 

public class districts : INotifyPropertyChanged 
 {
       public event PropertyChangedEventHandler PropertyChanged;   
       #region Public Constructors     
       /// <summary>
       /// Treeview class data definition
       /// </summary>
       /// <param name="districtId"></param>
       /// <param name="parentDistrictId"></param>
       /// <param name="description"></param>
       /// <param name="childrenDistricts"></param>
       public districts(string districtId, string parentDistrictId, string description, List<districts> childrenDistricts)
 {
  this.DistrictId = districtId;
  this.ParentDistrictId = parentDistrictId;
  this.Description = description;
  this.ChildrenDistricts = childrenDistricts;
 }
 #endregion Public Constructors
 
 #region Public Properties
 
 public List<districts> ChildrenDistricts { get; set; }
 public string Description { get; set; }
 public string DistrictId { get; set; }
 public string ParentDistrictId { get; set; }
 public bool Checked { get; set; }      
 #endregion Public Properties   
}

3 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 09 Aug 2016, 07:34 AM
Hello Leonard,

Thank you for writing. 

Please refer to the following help articles demonstrating how to bind the checkboxes in RadTreeView by specifying the CheckedMember property:
- self-reference data: http://docs.telerik.com/devtools/winforms/treeview/data-binding/binding-to-self-referencing-data
- object-relational data: http://docs.telerik.com/devtools/winforms/treeview/data-binding/binding-to-object-relational-data

The provided Districts class contains the ParentDistrictId property which is relevant for the self-referencing data as well as the ChildrenDistricts collection associated with the object-relational data. Feel free to use one of the above-mentioned approaches for the hierarchy setup according to the exact data that you have: either all records are available in the main list and the ParentDistrictId determines which is the parent node or don't use the ParentDistrictId property, but the ChildrenDistricts collection specifying the child nodes.

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
0
Leonard
Top achievements
Rank 1
answered on 09 Aug 2016, 03:45 PM

I have the binding working for checked state using the checked member my next question is that it changed the way the tree view control displays the top nodes checked even when only one of the sub nodes is checked. I have the checkboxes set up for tristate and in the binding using the CheckedMember I do not get the indeterminate value showing in the top node but in the sub node 000 it is indeterminate. I have added two pictures show when I do  and do not use CheckedMember for display purposes. Is there another property that should be set or is that the way the control should work

 

Leonard

0
Hristo
Telerik team
answered on 12 Aug 2016, 12:56 PM
Hi Leonard,

Thank you for writing back.

The reason for the described behavior is an issue in RadTreeViewADD. RadTreeView - binding the check-boxes to support TriStateMode. The feedback item also provides a workaround solution. Basically, you need to sync the state manually.

I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms. For more information check out this blog post and share your thoughts.
Tags
Treeview
Asked by
Leonard
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Leonard
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or