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

VirtualQueryableCollectionView grouping

7 Answers 166 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 10 Apr 2012, 06:17 PM
I am currently working on a solution where I wanted to use Ideablade DevForce as source for the grid. I already found a good solution on your forums to get this working. I added grouping support with the following code (this is called from the LoadData event):

public void LoadData(int startIndex, int itemCount)
        {
            var baseQuery = (EntityQuery<T>) Query
                                                 .Where(FilterDescriptors);
            baseQuery = (EntityQuery<T>) Query.GroupBy(GroupDescriptors);
            // Skip needs an order
            // if (SortDescriptors.Count == 0)//   SortDescriptions.Add(new SortDescription(InitialOrderBy.ToString(), InitialOrderByDirection));
            //SortDescriptions.Add(new SortDescription("Sid", ListSortDirection.Ascending));
 
            var resultQuery = (EntityQuery<T>) QueryableExtensions.Take(baseQuery
                                                                            .Sort(SortDescriptors)
                                                                            .Skip(startIndex), itemCount);
 
            resultQuery.QueryStrategy = new QueryStrategy(FetchStrategy.DataSourceAndCache,
                                                          MergeStrategy.PreserveChanges);
 
 
            resultQuery.ExecuteAsync().Completed += (s, e) => { Load(startIndex, e.Results); };
        }

The only problem I have is that if I group before all the items are loaded nothing gets loaded anymore. In my example I load 20 lines from 100 total lines. If I scroll down after I grouped the items no ItemChanged is sent from the grid.

Another problem I found was that the grid seems to be a bit too "eager" when loading data. This means that if the user tries to scroll to the bottom - without any interrest in the data in the middle - the grid always calls the loading method instead of waiting for the user to finish.

BTW: does the grid create all empty lines on the start or is there some internal limit to this? It just looked to me if the grid creates as many empty lines as the number in VirtualItemCount.

7 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 11 Apr 2012, 08:13 AM
Hi,

 Virtualization of group items is not supported. Indeed the collection will create VirtualItemCount null items initially and later will replace these items when you load them.

Regards,
Vlad
the Telerik team

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

0
Thomas
Top achievements
Rank 1
answered on 11 Apr 2012, 08:50 AM
Does that mean that if I have a query that returns 1 million records the grid would create 1 million empty lines also if it is used with the paging option (so that it would only have for example 20 real records returned from the query).
0
Vlad
Telerik team
answered on 11 Apr 2012, 08:52 AM
Hello,

 Indeed the collection will create 1 million empty items.

Regards,
Vlad
the Telerik team

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

0
Thomas
Top achievements
Rank 1
answered on 11 Apr 2012, 08:58 AM
Is there a way to get paging and grouping with a custom datasource working? 
0
Vlad
Telerik team
answered on 11 Apr 2012, 09:00 AM
Hello,

Maybe if you want paging and grouping the best way will be to use QueryableCollectionView instead VirtualQueryableCollectionView. You just need to provide IQueryable as source for our queryable collection and everything will work automatically. 

All the best,
Vlad
the Telerik team

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

0
Thomas
Top achievements
Rank 1
answered on 11 Apr 2012, 01:35 PM
Does that mean that I would need to use a DataPager or some other paging mechanism or would that work just by using the scrollbar?
0
Vlad
Telerik team
answered on 11 Apr 2012, 01:45 PM
Hello,

 Indeed paging usually is associated with pager component. The virtual collection is a bit more complex and is designed to work with scrolling mostly. 

All the best,
Vlad
the Telerik team

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

Tags
GridView
Asked by
Thomas
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Thomas
Top achievements
Rank 1
Share this question
or