How to remove treeviewlist item

5 posts, 0 answers
  1. Jane
    Jane avatar
    6 posts
    Member since:
    Apr 2010

    Posted 12 May 2010 Link to this post

    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!     

  2. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 13 May 2010 Link to this post

    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.
  3. DevCraft banner
  4. Jane
    Jane avatar
    6 posts
    Member since:
    Apr 2010

    Posted 13 May 2010 Link to this post

    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?

  5. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 18 May 2010 Link to this post

    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.
  6. Jane
    Jane avatar
    6 posts
    Member since:
    Apr 2010

    Posted 18 May 2010 Link to this post

    This works. Thank you very much.
Back to Top
DevCraft banner