Binding to a object with checked state being updated.

4 posts, 0 answers
  1. Leonard
    Leonard avatar
    2 posts
    Member since:
    Oct 2014

    Posted 05 Aug Link to this post

    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   
    }

  2. Dess
    Admin
    Dess avatar
    1602 posts

    Posted 09 Aug Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Leonard
    Leonard avatar
    2 posts
    Member since:
    Oct 2014

    Posted 09 Aug in reply to Dess Link to this post

    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

  5. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    710 posts

    Posted 12 Aug Link to this post

    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.
Back to Top