Pinned (Fixed) Columns
- 3 minutes to read
The Pivot Grid Control allows you to pin columns to the left or rightmost edge. The pinned columns are never scrolled horizontally, so you can use them as a reference point for adjacent cell values.
Pin Columns in UI
To pin or unpin a column, right-click the column’s header and select the corresponding command:
Set the PivotGridOptionsMenu.EnablePinColumnMenu property to false to remove the command from the column’s header context menu.
Pin Columns in Code
To pin a column, follow the steps below:
- Create a FixedFieldValue object.
- Assign a DataField to the FixedFieldValue.DataField property. If the Pivot Grid control displays multiple data fields, pick a field whose values should be pinned. The example below uses “fieldQuantity” - the only available data field.
- Create a FixedFieldValueCondition and specify a column area field and its value. This information, together with the data field, indicates the column that should be pinned. In the example below, the control pins ‘fieldQuantity’ values displayed under “February 2015” (a value of ‘fieldYear’).
- Add the created condition to the Conditions collection.
- Add the created FixedFieldValue object to the PivotGridControl.FixedColumnFieldValues collection.
The code snippet below illustrates how to pin the fieldQuantity field values that belong to the February 2015 interval.
using DevExpress.XtraPivotGrid;
//...
public Form1() {
var info = new FixedFieldValue(fieldQuantity);
info.Conditions.Add(
new FixedFieldValueCondition(fieldYear, new DateTime(2015, 2, 1)));
pivotGridControl1.FixedColumnFieldValues.Add(info);
}
If you specify no conditions, the “Grand Total” column is pinned.
To change the pinned column’s location, use the PivotGridOptionsView.FixedColumnLocation property. The default position is left.
Use the following API members:
API | description |
---|---|
FixedFieldValue | A column field value to be pinned. |
FixedFieldValueCondition | A condition used to identify the column to pin. |
FixedFieldValue.Conditions | Specifies field values that should be pinned. |
FixedFieldValue.DataField | Gets or sets the data field. Displayed cells’ values in the fixed column are calculated against this data field. |
FixedFieldValueCondition.Field | Gets or sets the field from the column area. Displayed cells’ values in the fixed column are calculated against this field. |
FixedFieldValueCondition.Value | Gets or sets the value of the field to be pinned. |
FixedFieldValueConditionCollection.AddRange | Adds conditions that identify the columns to be pinned to the FixedFieldValueCollection |
PivotGridOptionsMenu.EnablePinColumnMenu | Gets or sets whether users can invoke the column header context menu. |
Tip
Demo: Pinned Columns module in the XtraPivotGrid MainDemo
Requires a WinForms Subscription. Download
Limitations
Fixed columns have the following limitations:
- You cannot pin custom totals.
- In Legacy and Legacy-optimized mode, the values in the pinned column are not displayed if you collapse the corresponding column in the scrollable area.