Provides an abstract base class for collection views that support filtering, sorting, grouping, and paging operations on strongly-typed data item collections.
RadCollectionView serves as the foundation for data binding scenarios in RadControls, providing a rich set of data manipulation capabilities including filtering, sorting, grouping, and paging. It implements multiple collection interfaces to ensure compatibility with various data binding patterns and frameworks.
The collection view acts as a layer between raw data sources and UI controls, allowing for complex data operations without modifying the underlying data. It supports expression-based filtering, multi-level sorting, hierarchical grouping, and efficient pagination for large datasets.
Key features include change notifications through INotifyCollectionChanged and INotifyPropertyChanged, current item tracking, deferred refresh capabilities, and thread-safe operations for multi-threaded environments.
Definition
Namespace:Telerik.WinControls.Data
Assembly:Telerik.WinControls.dll
Type Parameters:
TDataItem
The type of data items in the collection, which must implement IDataItem.
Syntax:
public abstract class RadCollectionView<TDataItem> : ICollectionView<TDataItem>, IPagedCollectionView, IReadOnlyCollection<TDataItem>, IEnumerable, INotifyCollectionChanged, INotifyPropertyChanged where TDataItem : IDataItem
Inheritance: objectRadCollectionView<TDataItem>
Derived Classes:
Implements:
Constructors
Initializes the view from a source sequence and subscribes to its collection notifications when available.
public RadCollectionView(IEnumerable<TDataItem> collection)
The sequence whose items are projected by the view.
Exceptions: ArgumentNullExceptioncollection is null.
Properties
Gets or sets a value indicating whether filtering will be performed or it will be handled by the user/data source.
[Browsable(false)]
public bool BypassFilter { get; set; }
Gets or sets a value indicating whether sorting will be performed or it will be handled by the user/data source.
[Browsable(false)]
public bool BypassSort { get; set; }
Gets a value that indicates whether the IPagedCollectionView.PageIndex value is allowed to change.
public virtual bool CanChangePage { get; }
true if the IPagedCollectionView.PageIndex value is allowed to change; otherwise, false.
Implements:
Gets or sets a value indicating whether this data view can filter.
public virtual bool CanFilter { get; set; }
true if this instance can filter; otherwise, false.
Implements:
Gets or sets a value indicating whether this data view can group.
public virtual bool CanGroup { get; set; }
true if this instance can group; otherwise, false.
Implements:
Gets or sets a value indicating whether this data view can be paginated.
public virtual bool CanPage { get; set; }
true if this data view can be paginated; otherwise, false.
Implements:
Gets or sets a value indicating whether this data view can sort.
public virtual bool CanSort { get; set; }
true if this instance can sort; otherwise, false.
Implements:
Indicates whether string comparisons of data are case-sensitive.
[Browsable(true)]
public bool CaseSensitive { get; set; }
Gets or sets a value indicating whether [change current on add].
public bool ChangeCurrentOnAdd { get; set; }
true if [change current on add]; otherwise, false.
Comparer
IComparer<TDataItem>
Gets or sets the comparer.
[Browsable(false)]
public virtual IComparer<TDataItem> Comparer { get; set; }
The comparer.
CurrentItem
TDataItem
Gets or sets the current item.
public TDataItem CurrentItem { get; }
The current item.
Implements:
Gets or sets the current position.
public int CurrentPosition { get; protected set; }
The current position.
Implements:
DefaultFilter
Predicate<TDataItem>
Default callback so that the default filtering expression parser can be substituted.
public virtual Predicate<TDataItem> DefaultFilter { get; }
DefaultGroupPredicate
GroupPredicate<TDataItem>
Gets the default group predicate.
public virtual GroupPredicate<TDataItem> DefaultGroupPredicate { get; }
The default group predicate.
Provides a callback so that the default filtering expression parser can be substituted.
public virtual Predicate<TDataItem> Filter { get; set; }
Implements:
Gets or sets the filter expression.
public virtual string FilterExpression { get; set; }
The filter expression.
GroupComparer
IComparer<Group<TDataItem>>
Gets or sets the comparer.
[Browsable(false)]
public virtual IComparer<Group<TDataItem>> GroupComparer { get; set; }
The comparer.
Implements:
This property is used internally.
public IGroupDescriptorCollectionFactory GroupDescriptorCollectionFactory { get; set; }
Gets the group descriptions.
public GroupDescriptorCollection GroupDescriptors { get; }
The group descriptions.
Implements:
GroupFactory
IGroupFactory<TDataItem>
Gets or sets the factory used to create groups for this view.
public virtual IGroupFactory<TDataItem> GroupFactory { get; set; }
GroupPredicate
GroupPredicate<TDataItem>
Gets or sets the callback used by derived views to compute group keys.
public virtual GroupPredicate<TDataItem> GroupPredicate { get; set; }
The base implementation returns null and ignores assignments.
Groups
GroupCollection<TDataItem>
Gets the groups.
public virtual GroupCollection<TDataItem> Groups { get; }
The groups.
Implements:
Indicates whether filtering, sorting, or grouping is active.
protected bool HasDataOperation { get; }
Gets a value indicating whether this instance has filter applied.
protected bool HasFilter { get; }
true if this instance has filter applied; otherwise, false.
Gets a value indicating whether this instance has group applied.
protected bool HasGroup { get; }
true if this instance has group applied; otherwise, false.
Gets a value indicating whether this instance has sort applied.
protected bool HasSort { get; }
true if this instance has sort applied; otherwise, false.
Gets a value that indicates whether the underlying collection provides change notifications.
public bool IsDynamic { get; }
true if this instance is dynamic; otherwise, false.
Gets a value indicating whether this item collection is empty.
public bool IsEmpty { get; }
true if this item collection is empty; otherwise, false.
Gets a value indicating whether this instance is incremental filtering.
public bool IsIncrementalFiltering { get; }
true if this instance is incremental filtering; otherwise, false.
Indicates whether the view is inside a deferred update.
protected bool IsInUpdate { get; }
Gets a value that indicates whether a page index change is in process.
public virtual bool IsPageChanging { get; }
true if the page index is changing; otherwise, false.
Implements:
Gets the total number of items in the source collection.
public virtual int ItemCount { get; }
The total number of items in the source collection, or -1 if the total number is unknown.
Implements:
Items
IList<TDataItem>
Gets the item list exposed by a derived view.
protected virtual IList<TDataItem> Items { get; }
The base implementation returns null; derived views provide the collection used by indexing and enumeration.
Gets the zero-based index of the current page.
public virtual int PageIndex { get; }
The zero-based index of the current page.
Implements:
Gets or sets the number of items to display on a page.
public virtual int PageSize { get; set; }
The number of items to display on a page.
Implements:
Gets or sets a value indicating whether paging is performed before grouping or vice versa.
public virtual bool PagingBeforeGrouping { get; set; }
true if paging is performed before grouping; otherwise, false.
This property is used internally.
public ISortDescriptorCollectionFactory SortDescriptorCollectionFactory { get; set; }
Gets the sort descriptions.
public SortDescriptorCollection SortDescriptors { get; }
The sort descriptions.
Implements:
SourceCollection
IEnumerable<TDataItem>
Gets the source collection.
public virtual IEnumerable<TDataItem> SourceCollection { get; }
The source collection.
Implements:
this[int]
TDataItem
Gets the item at the specified index.
Gets the total number of pages with the current page size.
public virtual int TotalPages { get; }
Methods
Suspends event notification.
public void BeginUpdate()
Clears cached filter-expression nodes and their per-thread evaluation contexts.
public void ClearThreadedFilterNodes()
Determines whether [contains] [the specified item].
public bool Contains(TDataItem item)
The item.
Returns:true if [contains] [the specified item]; otherwise, false.
Implements:
Copies to array.
public void CopyTo(TDataItem[] array, int arrayIndex)
The array.
arrayIndexintIndex of the array.
Defers the refresh.
Resumes event notification.
public void EndUpdate()
Resumes event notification.
Provides a hook for derived views to resolve descriptor metadata before data operations.
public virtual void EnsureDescriptors()
The base implementation does nothing.
Ensures the index of the page is within the valid pages range.
protected virtual void EnsurePageIndex()
Evaluates a descriptor expression against one item using this view's case-sensitivity setting.
public bool FilterEvaluate(FilterDescriptor filterDescriptor, TDataItem item)
The descriptor whose expression supplies the filter criteria.
itemTDataItemThe item whose descriptor fields are evaluated.
Returns:true when the descriptor has no expression or evaluates to a Boolean value of true; non-Boolean results also pass.
Enumerates the items currently exposed by the view.
public IEnumerator<TDataItem> GetEnumerator()
IEnumerator<TDataItem>
Gets a field value used when evaluating a filter expression.
Gets the page containing an item when a derived view supports paging.
public virtual int GetItemPage(TDataItem item)
The item whose page is requested.
Returns:The zero-based page index, or -1 when the base implementation cannot provide one.
Indexes the of.
public virtual int IndexOf(TDataItem item)
The item.
Returns:Implements:
Replaces the source sequence and updates the collection-change subscription.
protected virtual void InitializeSource(IEnumerable<TDataItem> collection)
The sequence to observe and project.
Collection notifications are observed only when the sequence implements INotifyCollectionChanged.
Loads the data.
public virtual void LoadData(IEnumerable<TDataItem> collection)
The collection.
Moves the current to.
public bool MoveCurrentTo(TDataItem item)
The item.
Returns:Implements:
Moves the current to first.
Moves the current to last.
Moves the current to next.
Moves the current to previous.
Sets the first page as the current page.
public virtual bool MoveToFirstPage()
true if the operation was successful; otherwise, false.
Implements:
Sets the last page as the current page.
public virtual bool MoveToLastPage()
true if the operation was successful; otherwise, false.
Implements:
Moves to the page after the current page.
public virtual bool MoveToNextPage()
true if the operation was successful; otherwise, false.
Implements:
Moves to the page before the current page.
public virtual bool MoveToPreviousPage()
true if the operation was successful; otherwise, false.
Implements:
Raises a view-change notification and updates the view version when the change can affect its projection.
protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs args)
The collection change to publish.
Raises CurrentChanged when the view is not inside a deferred update.
protected virtual void OnCurrentChanged(EventArgs args)
The event data describing the current-item change.
Raises CurrentChanging when the view is not inside a deferred update.
protected virtual void OnCurrentChanging(CancelEventArgs args)
The event data; a handler can set Cancel to prevent the change.
Raises the NotifyPropertyChanged event
protected virtual void OnNotifyPropertyChanged(PropertyChangedEventArgs e)
Fires the PageChanged event.
protected virtual void OnPageChanged()
Passeses the filter.
Processes a source collection change by forwarding it to OnCollectionChanged(NotifyCollectionChangedEventArgs).
protected virtual void ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
The source collection change.
Refreshes this data view.
public virtual void Refresh()
Implements:
Raises a reset notification unless a deferred update is in progress.
protected virtual void RefreshOverride()
Updates the current position and raises the corresponding changing and changed notifications.
protected bool SetCurrentPositionCore(int newPosition, bool forceNotify, CurrentChangeReason reason)
The requested zero-based position; values beyond the last item are reduced to the last position.
forceNotifybooltrue to process the change even when the position is unchanged.
reasonCurrentChangeReasonThe reason included in the current-item change event data.
Returns:true when the position update is accepted; false when it is unchanged or canceled.
The core update routine for the current position.
Determines whether a source change requires the view version to advance.
protected virtual bool VersionUpdateNeeded(NotifyCollectionChangedEventArgs args)
The source collection change.
Returns:true for structural changes or changes to fields used by filtering, sorting, or grouping.
Events
Occurs when the view's projected items change.
public event NotifyCollectionChangedEventHandler CollectionChanged
Implements:
Occurs after the current item or position changes, except while an update is deferred.
public event EventHandler CurrentChanged
Implements:
Occurs before the current item or position changes, allowing the change to be canceled.
public event CancelEventHandler CurrentChanging
Implements:
Occurs when the IPagedCollectionView.PageIndex has changed.
public event EventHandler<EventArgs> PageChanged
Implements:
Occurs before the IPagedCollectionView.PageIndex is changed.
public event EventHandler<PageChangingEventArgs> PageChanging
Implements:
Occurs when a view property, such as its filter or descriptor collection, changes.
public event PropertyChangedEventHandler PropertyChanged
Implements: