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

VirtualQueryableCollectionView not working

3 Answers 185 Views
Data Virtualization
This is a migrated thread and some comments may be shown as answers.
Ladislav
Top achievements
Rank 1
Ladislav asked on 16 Aug 2011, 11:24 AM
Hi,

I have problem with virtualizing RadGridView in silverlight with VirtualQueryableCollectionView. Everything works fine, till I add or delete row in grid. When it happened, I programatically change property VirtualItemCount, so it will force event ItemsLoading. Problem is, it will ask only for newly added item and rest is shown as empty rows. I know, that when VirtualItemCount is changed, it internally clears all rows. But I would expect when data is needed again, it will ask for them in ItemsLoading event. I can post sample application to demonstrate this. How can I solve this issue?

I am using this in bigger application, when data is loading as needed from database. Is only solution to implement some external logic to load always full page and partly ignore received index and itemscount in ItemsLoading event? Other solution I know is to create new collection, when items count is changed, but than it will reload always first page, which is not wanted behaviour. (Calling MoveToPage after that not works either, it shows empty rows too on loaded page. This function even not change PageIndex in collection).

Thanks for response.

Ladislav

3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 22 Aug 2011, 08:11 AM
Hello Ladislav,

We will need some more time to investigate the case and provide an appropriate solution. Generally, it would be great if it is possible to send us a sample project as in that way we will be able to debug your exact scenario without any misunderstandings.
Thank you for your patience and collaboration.
 

All the best,
Maya
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Ladislav
Top achievements
Rank 1
answered on 22 Aug 2011, 12:39 PM
Hi,

Unfortunatelly I couldn't send project package due to not activated support. So I just post main part of code.

Its very simple application with 2 buttons - Add, Delete. First issue I have is with button Add. I am adding random items to collection and only last one is showing. (Setting VirtualItemsCount will internally clear all items.). I would expect that ItemsLoading event would ask for all needed items.

private void OnAddClick(object sender, System.Windows.RoutedEventArgs e)
      {
         var rnd = new Random();
         var data = new Data("random " + rnd.Next());
         dataList.Add(data);
 
         collection.VirtualItemCount = dataList.Count;      // force refresh
      }

datalist - internal collection of items
collection - VirtualQueryableCollectionView
RadGridView is binded to collection.
Here is my implementation of ItemsLoading event.
private void collection_ItemsLoading(object sender, VirtualQueryableCollectionViewItemsLoadingEventArgs e)
      {
         collection.Load(e.StartIndex, dataList.Skip(e.StartIndex).Take(e.ItemCount));
         if( goToPage != null ) // this is for Delete functiontionality
         {
            collection.MoveToPage(goToPage.Value); // does not work
            goToPage = null;
         }
      }


To counter this I try to create new collection every time total count is changed. Its implemented in delete button. When VirtualItemsCount is changed, I create new collection and on ItemsLoading event load data and move to page index where it was before. So u can simulate this issue by creating exactly 7 rows, going to page 2, delete last row. Now its showing one empty row on page 2, which is bug. If u go back to previous page and than back to second page, it is showing proper value.

private void OnDeleteClick(object sender, System.Windows.RoutedEventArgs e)
      {
         if( SelectedItem == null )
         {
            return;
         }
         dataList.Remove(SelectedItem);
        
         goToPage = collection.PageIndex;  // save page index. We will go on that page in ItemsLoading event
 
         collection.ItemsLoading -= collection_ItemsLoading;
 
         collection = new VirtualQueryableCollectionView() { PageSize = 5 };
         collection.ItemsLoading += collection_ItemsLoading;
         collection.LoadSize = 5;
 
         if( PropertyChanged != null )
         {
            PropertyChanged(this, new PropertyChangedEventArgs("Collection"));
         }
 
         collection.VirtualItemCount = dataList.Count;          
      }


I find other issue when adding more than 7 rows. It will start throwing exceptions when clicking on grid and grid start showing wierd values.

Ladislav
0
Maya
Telerik team
answered on 25 Aug 2011, 12:43 PM
Hi Ladislav,

Thank you for the additional information. I will let you once we have some more information for the issue. 

Kind regards,
Maya
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
Data Virtualization
Asked by
Ladislav
Top achievements
Rank 1
Answers by
Maya
Telerik team
Ladislav
Top achievements
Rank 1
Share this question
or