Since R2 2016, RadGridView supports Pinned Rows. By using Pinned Rows, you can pin particular rows to the top or bottom of your RadGridView so that they do not participate in the vertical scrolling.
In this article, we will discuss the following topics:
RadGridView's PinnedRowsPosition property lets you determine where the pinned rows will appear. It has three possible values:
Top: Display the pinned rows on top.
Bottom: Display the pinned rows at the bottom after the last standard row.
None: Do not display the pinned rows.
Example 1 shows that you can set the property either declaratively or at runtime, like this:
[XAML] Example 1: Setting the PinnedRowsPosition property
<telerik:RadGridView PinnedRowsPosition="Top" />
[C#] Example 1: Setting the PinnedRowsPosition property
this.RadGridView.PinnedRowsPosition = GridViewPinnedRowsPosition.Top;
[VB.NET] Example 1: Setting the PinnedRowsPosition property
Me.RadGridView.PinnedRowsPosition = GridViewPinnedRowsPosition.Top
If the PinnedRowsPosition property is set to either Top or Bottom, a pin button will appear on hovering over the row indicator.
Pinned rows are only supported when GroupRenderMode is set to Flat.
Pressing the button will pin the respective row. Clicking on it again will remove it from the collection of the pinned rows.
Figure 1: Pinning rows from the row indicator
Another way to allow your users to pin rows with the click of a button is to define a GridViewPinRowColumn, which enables pinning and unpinning of the rows.
[XAML] Example 2: Defining a GridViewPinRowColumn
<telerik:RadGridView.Columns> <telerik:GridViewPinRowColumn /> </telerik:RadGridView.Columns>
Figure 2: Pinning rows from the GridViewPinRowColumn
Pinned items do not participate in grouping. Once the user applies grouping to RadGridView, either by dragging a column header to the GridViewGroupPanel, or programmatically, the pinned items are placed back to the Items collection. On ungrouping, they reappear as pinned.
Sorting a column results in sorting the items in the pinned panel as well - only compared to each other.
When the user pins rows in a page and moves to another page, the pinned rows are removed, as they are not a part of the source of the second page. Navigating back to the previous page would bring back the pinned rows for that page.
Filtering RadGridView displays all items (along with the pinned ones) in the filter descriptor.
The TogglePinnedRowState Command toggles a row's IsPinned property. It takes as parameters the item to pin and the target RadGridView to pin that item to.
[C#] Example 3: Using the TogglePinnedRowState Command
var togglePinnedStateCommand = RadGridViewCommands.TogglePinnedRowState as RoutedUICommand; togglePinnedStateCommand.Execute(this.RadGridView.Items, this.RadGridView);
[VB.NET] Example 3: Using the TogglePinnedRowState Command
Dim togglePinnedStateCommand = TryCast(RadGridViewCommands.TogglePinnedRowState, RoutedUICommand) togglePinnedStateCommand.Execute(Me.RadGridView.Items(0), Me.RadGridView)