Delete TreeListView items

7 posts, 1 answers
  1. Andreas
    Andreas avatar
    23 posts
    Member since:
    Feb 2011

    Posted 23 Feb 2011 Link to this post

    Hi,

    I'm creating a TreeListView on run time. As long as there is only one level in the tree I am able to delete the nodes with the delete key. When the tree gets more ramified it is not possible to delete the nodes using this key - either on the first level nor on the deeper levels. I'm not sure if the behaviour really depends on the depth of the levels the point is that sometimes it's possible to delete and sometimes it's not.
    I would like to be able to catch the delete key down event to remove the item from the source list in my viewmodel or to delete in the UI and have it updated in the observable collection in the viewmodel. What would be the best approach to this.

    Regards,

    Andreas
  2. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 24 Feb 2011 Link to this post

    Hi Andreas,

    I am trying to reproduce the erroneous behaviour here. Can you please help me with some details -

    what do you mean by "more ramified" - what is the type of the collection , the item and the count of the items you  are binding to .

    Any details which you think might help me reproduce the issue will be welcome.

    Regards,
    Pavel Pavlov
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  3. DevCraft banner
  4. Andreas
    Andreas avatar
    23 posts
    Member since:
    Feb 2011

    Posted 25 Feb 2011 Link to this post

    Hi Pavel,

    my problem is that I'm not able to delete the children nodes with the delete key. I've also tried to create a button like this
    <telerik:RadButton Content="Delete" Command="telerikGrid:RadGridViewCommands.Delete" CommandParameter="{Binding}" />
    with the same effect. The nodes on the first level are removed as expected.
    In my scenario I have a tree with ComboBoxes on the nodes. When I remove a node from the tree I have to add this item back in the lists of the ComboBoxes. So I have to be able to catch the delete event in my view model.

    Here is the TreeListView definition in XAML:

    <t:RadTreeListView x:Name="TreeListView"
                                     AutoGenerateColumns="False"
                                     ItemsSource="{Binding Zeile.Liste}"
                                     SelectedItem="{Binding Current, Mode=TwoWay}"
                                     CanUserReorderColumns="True"
                                     CanUserFreezeColumns="True"
                                     EnableColumnVirtualization="True"
                                     EnableRowVirtualization="True">

                    <t:RadTreeListView.ChildTableDefinitions>
                        <t:TreeListViewTableDefinition ItemsSource="{Binding Liste}"/>
                    </t:RadTreeListView.ChildTableDefinitions>
                    
                    <t:RadTreeListView.HierarchyChildTemplate>
                        <DataTemplate>
                            <t:RadTreeListView ItemsSource="{Binding Liste}"/>
                        </DataTemplate>
                    </t:RadTreeListView.HierarchyChildTemplate>

                    <t:RadTreeListView.Columns>
                        <t:GridViewComboBoxColumn Header="Bezeichnung"
                                                        DataMemberBinding="{Binding AuswahlListeId}"
                                                        ItemsSourceBinding="{Binding AuswahlListe}"
                                                        SelectedValueMemberPath="Id"
                                                        DisplayMemberPath="ManagementEigenschaftName">
                        
                            <t:GridViewComboBoxColumn.CellEditTemplate>
                                <DataTemplate>
                                    <Controls:RadComboBox ItemsSource="{Binding VerfuegbarListe}"
                                                          SelectedValue="{Binding AuswahlListeId, Mode=TwoWay}"
                                                          SelectedValuePath="Id"
                                                          DisplayMemberPath="ManagementEigenschaftName" />
                                </DataTemplate>
                            </t:GridViewComboBoxColumn.CellEditTemplate>
                        
                        </t:GridViewComboBoxColumn>

                        <t:GridViewDataColumn DataMemberBinding="{Binding Menge}"
                                                    IsReadOnly="True"
                                                    Header="Menge" />
                    </t:RadTreeListView.Columns>
                </t:RadTreeListView>

    the tree is filled with objects of the class Zeile. Here is the code:


        public class EigenschaftenListe : ObservableCollection<AuswahlManagementEigenschaft>
        {}

        public class ZeilenListe : ObservableCollection<IZeile>
        {}

        public interface IZeile
        {
            int EbenenTiefe { get; set; }
            int AuswahlListeId { get; set; }
            decimal Menge { get; set; }
            ZeilenListe Liste { get; set; }
            EigenschaftenListe AuswahlListe { get; set; }
            EigenschaftenListe VerfuegbarListe { get; set; }
            IZeile ElternKnoten { get; set; }
        }

        public class Zeile : IZeile, INotifyPropertyChanged
        {
            private int _ebenenTiefe;
            private int _id;
            private int _idVorher;
            private decimal _menge;
            private ZeilenListe _Liste;
            private EigenschaftenListe _auswahlListe;
            private EigenschaftenListe _verfuegbarListe;
            private IZeile _elternKnoten;

            public event PropertyChangedEventHandler PropertyChanged;

            #region Konstruktoren

            public Zeile()
            {
                _erzeugeListe();
            }
            public Zeile(IZeile ElternKnoten,
                         int EbenenTiefe,
                         EigenschaftenListe AuswahlListe,
                         EigenschaftenListe VerfuegbarListe,
                         decimal Menge)
            {
                _id = 0;
                _ebenenTiefe = EbenenTiefe;
                _menge = Menge;
                _auswahlListe = AuswahlListe;
                _verfuegbarListe = VerfuegbarListe;
                _elternKnoten = ElternKnoten;

                _erzeugeListe();
            }

    Many thanks for your help,

    Andreas
  5. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 04 Mar 2011 Link to this post

    Hello Andreas,

    Can you remove temporary this declaration to see what will be the result?  

      <t:RadTreeListView.HierarchyChildTemplate>
                        <DataTemplate>
                            <t:RadTreeListView ItemsSource="{Binding Liste}"/>
                        </DataTemplate>
                    </t:RadTreeListView.HierarchyChildTemplate>

    All the best,
    Vlad
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  6. Andreas
    Andreas avatar
    23 posts
    Member since:
    Feb 2011

    Posted 09 Mar 2011 Link to this post

    Hi Vlad,

    I removed the part of the XAML code that you have suggested but it doesn't make any difference.

    I took a telerik own sample 'first look' in 'RadControls for Silverlight Q3 2010 SP1' and changed
    in this line the IsReadOnly property to False like this:

    <telerik:RadTreeListView x:Name="RadTreeListView1"
                                     AutoGenerateColumns="False"
                                     IsReadOnly="False"
                                     ItemsSource="{StaticResource TreeListSource}">

    And I'm experiencing the same problem here. I can delete the first parent node but not the children nodes.

    Regards,

    Andreas
  7. Answer
    Maya
    Admin
    Maya avatar
    4062 posts

    Posted 15 Mar 2011 Link to this post

    Hello Andreas,

    We do managed to reproduce the issue you reported and it has been immediately fixed. It will be included in our upcoming official release Q1 2011.
    I have updated your Telerik point accordingly. 

    All the best,
    Maya
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  8. Andreas
    Andreas avatar
    23 posts
    Member since:
    Feb 2011

    Posted 16 Mar 2011 Link to this post

    Thanks for reply,

    Regards, Andreas
Back to Top
DevCraft banner