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

How to remove treeviewlist item

4 Answers 79 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Jane
Top achievements
Rank 1
Jane asked on 12 May 2010, 03:02 PM

I want to have a remove treeviewlist item function, I use the latest telerik Silverlight control (April, 2010),  VS 2010, entity framework, Ria service. I tried to remove the selected entity from entity collection directly, but the item still show on the treeviewlist even I set two way data binding mode for itemsource. Can you send me an example project that I can follow?  Thank you very much!     

4 Answers, 1 is accepted

Sort by
0
Miroslav
Telerik team
answered on 13 May 2010, 05:44 PM
Hello Jane,

If the ItemsSource of the TreeListView is observable it should update when an item is removed from its source.

I am attaching a project where this happens, using dummy data and an ObservableCollection<T>.

Is it possible that you are not assigning an observable source to the TreeListView?

Calling .ToList() for example will produce a non-observable collection.

Best wishes,
Miroslav
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Jane
Top achievements
Rank 1
answered on 14 May 2010, 12:29 AM

Thank you for your response.
I load my treeviewlist like this.

Ria service

 

public IQueryable<Group> GetGroups ()


on the Page code behind

var query = this.nbt.GetGroupsQuery();

var loadOperation = this.nbt.Load(query, LoadBehavior.RefreshCurrent, false);

 

this.groupTreeListView.ItemsSource = loadOperation.Entities.Where(t => t.ParentGroup == null);

on Xaml
<telerikNavigation:RadTreeListView telerik:StyleManager.Theme="Windows7" x:Name="groupTreeListView"> 

I can remove the group from entity collection and database but the treelistview doesn't get refreshed. 
How can I define databinding mode = "TwoWay" for itemsource in code behind?

0
Miroslav
Telerik team
answered on 18 May 2010, 02:44 PM
Hi Jane,

Calling Where() on an observable collection returns a WhereEnumerator which is a non-observable enumerator that just walks the given collection. It will not notify its destination if the source changes.

this.groupTreeListView.ItemsSource = loadOperation.Entities.Where(t => t.ParentGroup == null);

There is a way to achieve this using a CollctionView:

var collectionView = new CollectionViewSource();
collectionView.Source = loadOperation.Entities;
collectionView.Filter += (s, e) => (e.Item as MyDataItem).ParentGroup == null;
this.groupTreeListView.ItemsSource = collectionView;

Hopefully this will help you,

Regards,
Miroslav
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Jane
Top achievements
Rank 1
answered on 18 May 2010, 03:30 PM
This works. Thank you very much.
Tags
TreeListView
Asked by
Jane
Top achievements
Rank 1
Answers by
Miroslav
Telerik team
Jane
Top achievements
Rank 1
Share this question
or