Data Virtualization enables hassle-free loading of large amount of data in lesser period of time. It enables the List to download only the required screen-display information instead of the whole data.
The following GIF shows how data virtualization makes it convenient to render a large amount of data in List.
List supports virtualization of data to fetch the list of items as the user scrolls in real time. This data virtualization technique is supported in the List through DataCollection which provides C1VirtualDataCollection class for data virtualized collection views.
To enable virtualization in List, follow these steps:
C# |
Copy Code
|
---|---|
public class VirtualModeCollectionView : C1VirtualDataCollection<Customer> { public int TotalCount { get; set; } = 1_000; protected override async Task<Tuple<int, IReadOnlyList<Product>>> GetPageAsync(int pageIndex, int startingIndex, int count, IReadOnlyList<SortDescription> sortDescriptions = null, FilterExpression filterExpression = null, CancellationToken cancellationToken = default(CancellationToken)) { await Task.Delay(500, cancellationToken);//Simulates network traffic. return new Tuple<int, IReadOnlyList<Product>>(TotalCount, Enumerable.Range(startingIndex, count).Select(i => new Product(i)).ToList()); } } |
C# |
Copy Code
|
---|---|
//begins updating c1List1.BeginUpdate(); var collectionView = new VirtualModeCollectionView(); //sets the view c1List1.DataSource = new C1DataCollectionBindingList(collectionView); c1List1.EndUpdate(); |