VirtualQueryableCollectionView DevForce

2 posts, 0 answers
  1. Sven J
    Sven J avatar
    26 posts
    Member since:
    Nov 2009

    Posted 25 Nov 2011 Link to this post


    I'm trying to use the VirtualQueryableCollectionView to query data via DevForce/IdeaBlade. Unfortunately I'm facing a lot of problems. We use MVVM so my RadGridView binds to the VirtualQueryableCollectionView on my ViewModel. For better integration with DevForce I've inherited the collection and added some DevForce specific stuff.

    I want to sync grid data with DevForce's EntityManager Entites but adding and refreshing data doesn't work quite well with the VirtualQueryableCollectionView. Can someone give me a hint how I can handle that?


    Here is my class so far:
    public class EntityQueryableCollectionView<T> : VirtualQueryableCollectionView where T : Entity
           public IEntityQuery<T> Query { get; set; }
           public IEntityQuery<T> BaseQuery { get { return (EntityQuery<T>)Query.Where(FilterDescriptors); } }
           public Expression<Func<T, object>> InitialOrderBy { get; set; }
           public ListSortDirection InitialOrderByDirection { get; set; }
           public EntityQueryableCollectionView(IEntityQuery<T> query, Expression<Func<T, object>> orderBy, ListSortDirection direction = ListSortDirection.Ascending)
               : base()
               Query = query;
               InitialOrderBy = orderBy;
               InitialOrderByDirection = direction;
               LoadSize = 20;
               ItemsLoading += (s, e) => LoadData(e.StartIndex, e.ItemCount);
               FilterDescriptors.CollectionChanged += (s, e) => CountRecords();
               FilterDescriptors.ItemChanged += (s, e) => CountRecords();
           public void CountRecords()
               var countQuery = BaseQuery
               countQuery.Completed += (sender, args) => VirtualItemCount = args.Result;
           public void LoadData(int startIndex, int itemCount)
               var baseQuery = (EntityQuery<T>)Query
               // Skip needs an order
               if (SortDescriptors.Count == 0)
                   SortDescriptions.Add(new SortDescription(InitialOrderBy.AsString(), InitialOrderByDirection));
               var resultQuery = (EntityQuery<T>)baseQuery
               resultQuery.QueryStrategy = new QueryStrategy(FetchStrategy.DataSourceAndCache, MergeStrategy.PreserveChanges);
               resultQuery.ExecuteAsync().Completed += (s, e) =>
                   Load(startIndex, e.Results.Where(entity => entity.EntityAspect.EntityState.InList(EntityState.Added, EntityState.Modified, EntityState.Unchanged)));
           public new int Add(object item)
               var pos = base.Add(item);
               return pos;
           public override void Remove(object item)
               (item as Entity).EntityAspect.Delete();
  2. Vlad
    Vlad avatar
    11100 posts

    Posted 30 Nov 2011 Link to this post


     Currently the virtual collection can be used mostly for read-only scenarios. Please add/remove items in your original context and reload the virtual collection if/when needed. 

    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft R3 2016 release webinar banner
Back to Top