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

Delete TreeListView items

6 Answers 81 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Andreas
Top achievements
Rank 1
Andreas asked on 23 Feb 2011, 02:25 PM
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

6 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 24 Feb 2011, 07:45 PM
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!
0
Andreas
Top achievements
Rank 1
answered on 25 Feb 2011, 09:18 AM
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
0
Vlad
Telerik team
answered on 04 Mar 2011, 01:49 PM
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!
0
Andreas
Top achievements
Rank 1
answered on 09 Mar 2011, 10:05 AM
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
0
Accepted
Maya
Telerik team
answered on 15 Mar 2011, 09:23 AM
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!
0
Andreas
Top achievements
Rank 1
answered on 16 Mar 2011, 02:07 PM
Thanks for reply,

Regards, Andreas
Tags
TreeListView
Asked by
Andreas
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Andreas
Top achievements
Rank 1
Vlad
Telerik team
Maya
Telerik team
Share this question
or