Checkbox column and Checked event when row is expanding problem

4 posts, 0 answers
  1. tidesoftware
    tidesoftware avatar
    2 posts
    Member since:
    Dec 2010

    Posted 14 Dec 2010 Link to this post

    Hi

    I have simple TreeListView like this:

    01.<telerik:RadTreeListView x:Name="radtreelistviewGUIObjects" RowIsExpandedChanging="radtreelistviewGUIObjects_RowIsExpandedChanging" RowIsExpandedChanged="radtreelistviewGUIObjects_RowIsExpandedChanged" RowLoaded="radtreelistviewGUIObjects_RowLoaded" AutoGenerateColumns="False" Tag="3184">
    02.          <telerikGrid:RadTreeListView.ChildTableDefinitions>
    03.            <telerikGrid:TreeListViewTableDefinition ItemsSource="{Binding Items}" />
    04.          </telerikGrid:RadTreeListView.ChildTableDefinitions>
    05.          <telerikGrid:RadTreeListView.Columns>
    06.            <telerikGrid:GridViewDataColumn DataMemberBinding="{Binding Name}" Header="Element" MinWidth="300" />
    07.            <telerikGrid:GridViewDataColumn Header="Widoczny" CellTemplate="{StaticResource VisibleProperty}" />
    08.            <telerikGrid:GridViewDataColumn Header="Aktywny" CellTemplate="{StaticResource EnableProperty}" />
    09.            <telerikGrid:GridViewDataColumn Header="Tylko do odczytu" CellTemplate="{StaticResource ReadOnlyProperty}" />
    10.            <telerikGrid:GridViewDataColumn Header="Wersja" CellTemplate="{StaticResource VersionProperty}" />
    11.          </telerikGrid:RadTreeListView.Columns>
    12.        </telerik:RadTreeListView>

    and these templates:

    01.<telerik:HierarchicalDataTemplate x:Key="RadItem">
    02.            <TextBlock Text="{Binding Name}" VerticalAlignment="Center"/>
    03.        </telerik:HierarchicalDataTemplate>
    04.        <telerik:HierarchicalDataTemplate x:Key="VisibleProperty">
    05.            <CheckBox IsChecked="{Binding Visible, Mode=TwoWay}" Checked="VisibleCheckBox_Checked" Unchecked="VisibleCheckBox_Checked" HorizontalAlignment="Center" />
    06.        </telerik:HierarchicalDataTemplate>
    07.        <telerik:HierarchicalDataTemplate x:Key="EnableProperty">
    08.            <CheckBox IsChecked="{Binding Enable, Mode=TwoWay}" Checked="EnableCheckBox_Checked" Unchecked="EnableCheckBox_Checked" HorizontalAlignment="Center" />
    09.        </telerik:HierarchicalDataTemplate>
    10.        <telerik:HierarchicalDataTemplate x:Key="ReadOnlyProperty">
    11.            <CheckBox IsChecked="{Binding ReadOnly, Mode=TwoWay}" Checked="ReadOnlyCheckBox_Checked" Unchecked="ReadOnlyCheckBox_Checked" HorizontalAlignment="Center" />
    12.        </telerik:HierarchicalDataTemplate>
    13.        <telerik:HierarchicalDataTemplate x:Key="VersionProperty">
    14.            <TextBlock Text="{Binding Version}" VerticalAlignment="Center" HorizontalAlignment="Center" />
    15.        </telerik:HierarchicalDataTemplate>

    initializes this list in my source code:

    01.ObservableCollection<TreeRulesItem> ElementsTree = new ObservableCollection<TreeRulesItem>();
    02.  
    03.TreeRulesItem rulesItem = new TreeRulesItem();
    04.rulesItem.ID = 1;
    05.rulesItem.Name = "a";
    06.rulesItem.Version = 1;
    07.rulesItem.Visible = true;
    08.rulesItem.Enable = true;
    09.rulesItem.ReadOnly = true;         
    10.  
    11.this.ElementsTree.Add(rulesItem);
    12.  
    13.reeRulesItem childrulesItem = new TreeRulesItem();
    14.childrulesItem.ID = 2;
    15.childrulesItem.Name = "b";
    16.childrulesItem.Version = 1;
    17.childrulesItem.Visible = true;
    18.childrulesItem.Enable = true;
    19.childrulesItem.ReadOnly = true;
    20.rulesItem.Items.Add(childrulesItem);
    21.  
    22.TreeRulesItem childrulesItem2 = new TreeRulesItem();
    23.childrulesItem2.ID = 7;
    24.childrulesItem2.Name = "e";
    25.childrulesItem2.Version = 1;
    26.childrulesItem2.Visible = true;
    27.childrulesItem2.Enable = true;
    28.childrulesItem2.ReadOnly = true;
    29.childrulesItem.Items.Add(childrulesItem2);
    30.  
    31.childrulesItem2 = new TreeRulesItem();
    32.childrulesItem2.ID = 8;
    33.childrulesItem2.Name = "f";
    34.childrulesItem2.Version = 1;
    35.childrulesItem2.Visible = true;
    36.childrulesItem2.Enable = true;
    37.childrulesItem2.ReadOnly = true;
    38.childrulesItem.Items.Add(childrulesItem2);
    39.  
    40.childrulesItem = new TreeRulesItem();
    41.childrulesItem.ID = 3;
    42.childrulesItem.Name = "c";
    43.childrulesItem.Version = 1;
    44.childrulesItem.Visible = true;
    45.childrulesItem.Enable = true;
    46.childrulesItem.ReadOnly = true;
    47.rulesItem.Items.Add(childrulesItem);
    48.  
    49.childrulesItem = new TreeRulesItem();
    50.childrulesItem.ID = 4;
    51.childrulesItem.Name = "d";
    52.childrulesItem.Version = 1;
    53.childrulesItem.Visible = true;
    54.childrulesItem.Enable = true;
    55.childrulesItem.ReadOnly = true;
    56.rulesItem.Items.Add(childrulesItem);
    57.  
    58.radtreelistviewGUIObjects.ItemsSource = this.ElementsTree;

    where the class TreeRulesItem definition is:

    01.public class TreeRulesItem : INotifyPropertyChanged
    02.{
    03.        public long ID { get; set; }
    04.        public string Name { get; set; }
    05.        public ObservableCollection<TreeRulesItem> Items { get; set; }
    06.  
    07.        public int Version { get; set; }
    08.  
    09.        private bool? visible = null;
    10.        private bool? enable = null;
    11.        private bool? readOnly = null;
    12.  
    13.        public bool? Visible
    14.        {
    15.            get
    16.            {
    17.                return this.visible;
    18.            }
    19.            set
    20.            {
    21.                if (this.visible != value)
    22.                {
    23.                    this.visible = value;
    24.                    this.OnPropertyChanged("Visible");
    25.                }
    26.            }
    27.        }
    28.  
    29.        public bool? Enable
    30.        {
    31.            get
    32.            {
    33.                return this.enable;
    34.            }
    35.            set
    36.            {
    37.                if (this.enable != value)
    38.                {
    39.                    this.enable = value;
    40.                    this.OnPropertyChanged("Enable");
    41.                }
    42.            }
    43.        }
    44.  
    45.        public bool? ReadOnly
    46.        {
    47.            get
    48.            {
    49.                return this.readOnly;
    50.            }
    51.            set
    52.            {
    53.                if (this.readOnly != value)
    54.                {
    55.                    this.readOnly = value;
    56.                    this.OnPropertyChanged("ReadOnly");
    57.                }
    58.            }
    59.        }
    60.  
    61.        public event PropertyChangedEventHandler PropertyChanged;
    62.  
    63.        private void OnPropertyChanged(string propertyName)
    64.        {
    65.            if (this.PropertyChanged != null)
    66.            {
    67.                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    68.            }
    69.        }
    70.  
    71.        public TreeRulesItem()
    72.        {
    73.            this.Items = new ObservableCollection<TreeRulesItem>();
    74.        }
    75.}

    But when I expanding b element Checked event is triggered for elements b, c, d, e, f instead of e and f. Why is this happening or whether it is possible to distinguish between programmatically call the event and the call manually - when someone check the filed.

  2. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 16 Dec 2010 Link to this post

    Hi Tomas,

    Looking at the code snippet provided I need to know what happened behind RowIsExpandedChanging and RowIsExpandedChanged events of RadTreeListView? It could be great if you can send us a small application with full source code so that we can investigate the issue on our side.
    Thank you!

    Regards,
    Vanya Pavlova
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  3. DevCraft banner
  4. tidesoftware
    tidesoftware avatar
    2 posts
    Member since:
    Dec 2010

    Posted 16 Dec 2010 Link to this post

    Hi

    I sent you entire solution with attachment to support ticket (ID : 377019).

    Thanks.

  5. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 20 Dec 2010 Link to this post

    Hi,

     Why not use Click event instead Checked/Unchecked? Generally these events (Checked/Unchecked) will be raised on every CheckBox initialization however the Click event will be raised only when the user clicks on the CheckBox. 

    With our upcoming service pack we've changed the expand/collapse logic because of performance reasons and now both commands will work with Reset command for the internal collection - you will get these events for all levels with the new version.

    Best wishes,
    Vlad
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
Back to Top