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

VirtualQueryableCollectionView custum grouping

3 Answers 171 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Josef
Top achievements
Rank 1
Josef asked on 26 Apr 2011, 04:46 PM
I have my custom VirtualQueryableCollectionView to connect to my database.
I can read data an sorting. Now i would like to do grouping. When i drag and drop column to group panel to group by this column it creates one group expander with null value. When i expand this expander there is all my grid row.
Can you help me how can i create my custom grouping?

Thanks Josef.
public class VirtualQuery : VirtualQueryableCollectionView
   {
 
       WPF.Models.VirtualQuery _cacheVirtualQuery;
       CacheConnection _conn;
       public VirtualQuery(WPF.Models.VirtualQuery cacheVirtualQuery)
       {
           LoadSize = 1000;
           _cacheVirtualQuery = cacheVirtualQuery;
           _conn = cacheVirtualQuery.Connection;
           _cacheVirtualQuery.CreateQuery();
           VirtualItemCount = Convert.ToInt16(_cacheVirtualQuery.VirtualItemCount);
           ItemsLoading += VirtualQuery_ItemsLoading;
       }
 
 
       private void VirtualQuery_ItemsLoading(object sender, VirtualQueryableCollectionViewItemsLoadingEventArgs e)
       {
           SetUpCacheQuery();
           _cacheVirtualQuery.ItemsLoading(e.StartIndex, e.ItemCount);
           VirtualItemCount = Convert.ToInt16(_cacheVirtualQuery.VirtualItemCount);
           #region smazat dynamicky objekt pomale
           /*CacheDynamicObject[] DataContext = new CacheDynamicObject[_cacheVirtualQuery.QueryItems.Count] ;
           for (int i = 0; i < _cacheVirtualQuery.QueryItems.Count; i++)
           {
               DataContext[i] = new CacheDynamicObject(_cacheVirtualQuery.QueryItems[i] as CacheArrayOfDataTypes);
           }*/
           #endregion
           object[] DataContext1 = new object[_cacheVirtualQuery.QueryItems.Count];
           for (int i = 0; i < _cacheVirtualQuery.QueryItems.Count; i++)
           {
               DataContext1[i] = new Dictionary<string, string>(_cacheVirtualQuery.QueryItems[i] as CacheArrayOfDataTypes); ;
           }
           Load(e.StartIndex, DataContext1);
           _cacheVirtualQuery.QueryItems.Clear();
           _cacheVirtualQuery.Connection.ForceSync();
       }
 
       private void SetUpCacheQuery()
       {
           _cacheVirtualQuery.SortDescriptors.Clear();
           foreach (Telerik.Windows.Controls.GridView.ColumnSortDescriptor item in SortDescriptors)
           {
               WPF.Models.SortDescriptor desc = new WPF.Models.SortDescriptor(_conn);
               desc.SortUniqueName =  item.Column.UniqueName;
               desc.SortDirection = item.SortDirection.ToString();
               _cacheVirtualQuery.SortDescriptors.Add(desc);
           }
       }
   }
grouping?

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 27 Apr 2011, 06:51 AM
Hello,

 Grouping with virtual collection is supported only when you provide IQueryable in the collection constructor. Loading groups/items using Load()/ItemsLoading is not supported. 

Greetings,
Vlad
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
Josef
Top achievements
Rank 1
answered on 27 Apr 2011, 09:27 AM
Thank you for your answer.
Is any idea, suggest or sample how implement IQueryable? I want to implemented IQueryable but i don't know how?

Josef.
0
Milan
Telerik team
answered on 27 Apr 2011, 10:25 AM

Hello Josef,

You can find more information about Data Virtualization here. Regarding IQueryable, you can use Entity Framework context which is IQueryable and will allow you to have group, page, sort, filter on the server. 

// Entity Framework context
var context = new NorthwindEntities();
           var query = context.Order_Details.OrderBy(o => o.OrderID);
           var view = new VirtualQueryableCollectionView(query) { LoadSize = 10 };



Kind regards,
Milan
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
Tags
GridView
Asked by
Josef
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Josef
Top achievements
Rank 1
Milan
Telerik team
Share this question
or