Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue May 02, 2006 11:32 pm Post subject: How does Virtual Loading work? |
|
|
Virtual Tree is designed from the ground up to be data bound (it doesn't have an unbound mode). This means that it is in full control over the requesting of data from the data source and is able to leverage this to only request the data items that are required to support the current display.
Items displayed in the tree are obtained through the standard .NET IList interface. Virtual Tree uses three methods from this interface:
- Count - returns the number of items in the list. This is used by Virtual Tree to establish whether the expand icon should be shown next to the parent item (if the ChildPolicy for the row is not LoadOnExpand) and for expanded items is also used to determine the scrollbar dimensions and position.
- Item[index] - returns the item at a given index in the list. This is only called for those items that Virtual Tree is currently displaying. This means that even if your Data Source has 30000 items Virtual Tree will typically only call the Item method about 30 times to get the data to display the first 30 rows.
- IndexOf(Item) - returns the index of the given item in the list. This is used by VirtualTree when locating items within the tree hierarchy.
For simple in-memory data sources (such as an ArrayList) this design means that Virtual Tree does not spend time loading and creating visual representations for items which are never displayed.
More advanced data sources can implement the IList interface so that items are only loaded into memory as required. This can greatly reduce both the memory requirements and also initial load times for applications. Infralution's Virtual Data Objects uses this mechanism to allow browsing of very large databases using server side cursors - providing very quick startup times with minimal memory footprint.
You can also take advantage of this mechanism for your own data sources by simply implementing the IList interface for your own collection. The big advantage of leveraging the IList interface (as opposed to other virtual loading schemes) is that, because the virtual loading is defined in the data layer, all controls* and parts of your application that use the data source can take advantage of it.
* NOTE the standard .NET ListBox and ComboBox controls do not make intelligent use of the IList interface when using databinding. Instead they iterate through the entire collection (twice ) when data source is set. For this reason Infralution includes VirtualListBox and VirtualDropDownList controls when you purchase Virtual Tree. _________________ Infralution Support |
|