Skip some items from observable collection before binding

2 posts, 0 answers
  1. Ilias
    Ilias avatar
    9 posts
    Member since:
    Dec 2008

    Posted 09 May 2013 Link to this post

    Hi

    Here is my collection
    public ObservableCollection<dynamic> Items{get; set;}

    My binding is like:
    radGridView.ItemSource = Items.Where(i => i.IsVisible);

    So it is binding with Enumerable<dynamic> instead of Items and hence getting disconnected. Then if is add/delete any item in ObservableCollection<dynamic>, no reflection. I do not want to rebind grid as i need to preserve the scrolling.

    Please help me to find a solution.

    Thanx
    Ilias Hossain
  2. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2477 posts

    Posted 09 May 2013 Link to this post

    Hello,

    When you do a Where -- this returns a new collection, not the original one.

    Bind the grid to the original ObservableCollection<T>. Then add a FilterDescriptor to the grid which says that only visible items should pass the filter.

    More about programmatic filtering you can find in our online documentation.

    Greetings,
    Rossen Hristov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top