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

Reset individual items in VirtualQueryableCollectionView?

14 Answers 311 Views
Data Virtualization
This is a migrated thread and some comments may be shown as answers.
Timothy
Top achievements
Rank 1
Timothy asked on 30 Jan 2013, 09:34 PM
When a RadGridView's ItemSource is bound to a VirtualQueryableCollectionView, user navigation in the RadGridView causes the VirtualQueryableCollectionView to accumulate loaded objects.  From a memory management perspective we would like to be able to unload objects from the VirtualQueryableCollectionView - for example, we may want to unload anything outside the range of current row index +- 500 on an ongoing basis to limit our memory footprint.

The use case for this is any application where the user operates iteratively on a large set of large objects.  When moving down the list in the RadGridView, processed rows are never viewed again yet their associated objects remain in memory unavailable to the Garbage Collector. 

Unloading these objects from the collection should result in the objects being re-fetched by the ItemsLoading event handler if they are required for subsequent display in the RadGridView.

There appears to be no mechanism for identifying which items should and should not be unloaded.  ResetAll does as its name implies  - unloads all items - which is far too heavy handed for our desired behavior.

Setting an item to null (via RemoveAt(index), Insert(index, null) produces undesired behavior - the item is not refetched when its row is redisplayed, RadGridview displays an "=" in the row, and the item cannot be removed from the VirtualQueryableCollectionView (RemoveAt fails silently). 

QUESTION:  Is there a mechanism by which ranges of items can be reset in (unloaded from) a VirtualQueryableCollectionView?

I've accomplished this using reflection to remove items from the the private "loadedIndexes" collection but obviously would NOTdo that in production code.


Thanks,
tim

14 Answers, 1 is accepted

Sort by
0
Austin
Top achievements
Rank 1
answered on 30 Jan 2013, 09:48 PM
Hey Timothy,

Funny enough I asked this exact same question earlier today.  Here is the thread. 

http://www.telerik.com/community/forums/wpf/data-virtualization/question-data-virtualization-and-itemsloading.aspx

I ended up in the same place as you (using reflection to modify the loadedIndexes list).

0
Timothy
Top achievements
Rank 1
answered on 30 Jan 2013, 09:57 PM
I saw the subject of your thread and figured it had to do with a loading issue rather than unloading.  Reading it now I can see that my post is redundant - in a good way.  This is something that needs to be supported and shouldn't be left for tinkering via Reflection.

Given that the removal of items from the private collection has the desired effect - at least in terms of reloading them, it seems like it would be short work to support a public method that nulls the item and removes its entry from the loadedIndexes collection.  Even without the range overload, that would be VERY helpful (I'll write my own extension that wraps the single item reset if I have to).

Thanks for pointing this out, Austin.

Vlad, there are 2 of us now.  How about a Reset(startIndex, count) method???
0
Vlad
Telerik team
answered on 31 Jan 2013, 08:22 AM
Hello guys,

 You are absolutely right! 

We have already ResetItems() method for the virtual collection and we've added ResetItems(startIndex, count) overload. This will be part of our next internal build (next Monday). 

Thank you once again for your feedback! I've added 2000 Telerik to your accounts. 

Kind regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Timothy
Top achievements
Rank 1
answered on 31 Jan 2013, 01:51 PM
Thanks, Vlad!
0
Austin
Top achievements
Rank 1
answered on 31 Jan 2013, 01:59 PM
Sounds great, thanks for the quick action!
0
Jesse
Top achievements
Rank 1
answered on 31 Jan 2013, 04:27 PM
Vlad,

When you use the new ResetItems(startindex, count) method on a virtual collection will an associated RadGridView control immediately refresh the visible items? If not, what would be the best way to trigger the update to the visible items without resetting the control? In my case I am trying to get the item updates more than I am trying to release resources.

A possible way to automate the release of unused items would be to have a maximum page count in the collection and you could dispose of the least recently used page when the page count is exceeded. Setting the page count to cover 2 or 3 times the maximum number of viewable items should work nicely for a lot of one-way applications.

Thanks,

Jesse
0
Vlad
Telerik team
answered on 01 Feb 2013, 07:42 AM
Hi,

 Indeed RadGridView will automatically try to reload all reset items if they are in view. 

Kind regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
MarkInTexas
Top achievements
Rank 1
answered on 16 Nov 2014, 05:01 PM
I would like to use the above suggested approach as well.
Any chance there is an example like the suggested use in this thread.
Thanks for the help.
0
MarkInTexas
Top achievements
Rank 1
answered on 16 Nov 2014, 05:11 PM
Little more info.

I have an event log displayed in a grid.
As time goes by, the event log gets quite large.
New items are being added via application events and background processes etc.
The grid shows the newly added records and user of course can scroll through and view all the records.
I need to keep the memory footprint of the virtual collection small, like suggested above.
Having a mental lapse on exactly how to do this. Hence the example or approach would be most helpful.
Hope that helps explain my goal, let me know if more information is required.
Thanks again,
Mark.
0
Dimitrina
Telerik team
answered on 17 Nov 2014, 03:33 PM
Hello Mark,

In order to reset a smaller load size, you can invoke the ResetItems(int startIndex, int count) to reset just some items or the ResetItems() method to reset all of them. 

Please note that the ResetItems() method will not raise Reset CollectionChange, as the Refresh() will do, however it will set null for all the loaded items. 

Regards,
Dimitrina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
MarkInTexas
Top achievements
Rank 1
answered on 17 Nov 2014, 03:59 PM
Thanks for the information.

I was wondering what event should I be monitoring - do I monitor an event off the radgrid or the virtual collection.

For example, if table contains say 200,000 and then scroll all the way down to the end of the table then return back to the beginning.

When and where should I call the reset method?

Thanks,
Mark.


0
MarkInTexas
Top achievements
Rank 1
answered on 19 Nov 2014, 01:44 PM
An example of using the ResetItems + RadGrid would be great!
Thanks,
Mark.
0
Dimitrina
Telerik team
answered on 19 Nov 2014, 02:17 PM
Hello,

As it turns out there is not a event I can suggest to know when the ResetItems method should be invoked. Basically, the virtual collection was designed for ReadOnly purposes only and it is not recommended to be used in other scenarios when updates are required. 

I attached a demo project illustrating how to use the ResetItems method.

Regards,
Dimitrina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
MarkInTexas
Top achievements
Rank 1
answered on 19 Nov 2014, 06:26 PM
Thanks Vlad, the example is useful.
I see how it works now.
Tags
Data Virtualization
Asked by
Timothy
Top achievements
Rank 1
Answers by
Austin
Top achievements
Rank 1
Timothy
Top achievements
Rank 1
Vlad
Telerik team
Jesse
Top achievements
Rank 1
MarkInTexas
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or