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
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).
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???
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.
Vlad
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
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
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.
Any chance there is an example like the suggested use in this thread.
Thanks for the help.
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.
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.
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.
Thanks,
Mark.
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.
I see how it works now.