Pivot Grid Fields
- 3 minutes to read
Pivot Grid Fields supply data to PivotGridControl. Fields are visualized with field headers which you can drag-and-drop between the Pivot Grid areas. Dragging fields between areas modifies the report layout.
To create a report in PivotGridControl, create Pivot Grid fields and position them in the header areas. To perform these actions in code, follow the steps below:
- create a PivotGridField object and add it to the PivotGridControl.Fields collection;
- specify the field’s area and position within this area using the PivotGridFieldBase.Area and PivotGridFieldBase.AreaIndex properties (note that the PivotGridFieldBase.AreaIndex property can be set only after the field is added to the control’s field collection).
A field can be positioned within one of four areas: Column, Row, Data, and Filter Header Area. The field’s function is determined by an area in which it is located:
- position a field within the Column Header Area to list its values along the control’s top edge. Field’s values will be column headers;
- position a field within Row Header Area to list its values along the control’s left edge. Field’s values will be row headers;
- position a field within Data Header Area to calculate summaries against the fields. The summaries will be calculated for all the cells, each cell is identified by a column and a row;
- position a field within the Filter Header Area to make this field available for subsequent actions. End-users can drag the field to another area or filter a field using the Filter Dropdown.
To learn more, see the Field Layout section.
Pivot Grid supports bound and unbound fields. A bound field retrieves data from a Pivot Grid data source. An unbound field is not associated with a data source and should be populated with data manually. To learn more on unbound fields, see Unbound Fields.
To bind a Pivot Grid field to a data source field, set the PivotGridFieldBase.FieldName property to the name of the data source field. Note that the PivotGridFieldBase.UnboundType property is set to UnboundColumnType.Bound (default value). Otherwise, the field is unbound and the PivotGridFieldBase.UnboundType property specifies the field’s data type.
To learn more, see the Binding to Data section.
Pivot Grid can display only specific records by applying filter criteria to certain fields.
To learn more, see the Filtering section.
Use the following methods to obtain field data:
|PivotGridFieldBase.GetUniqueValues||Obtains an array of distinct field values from the underlying data source. This method is used to fill in field’s Filter Editors.|
|PivotGridFieldBase.GetAvailableValues||Obtains an array of distinct field values contained in the records which are left after applying filters to other fields.|
|PivotGridFieldBase.GetVisibleValues||Obtains a collection of unique field values contained in the records displayed in the Pivot Grid. Thus, these records are left after applying a field’s filter to the field’s available values (values contained in the records which are left after applying filters to other fields).|