Cell Editors Overview
- 3 minutes to read
Pivot Grid Control cells do not support data editing by default, and only display summary values calculated against data fields. You can customize cell text by formatting values or dynamically handling the PivotGridControl.CustomCellDisplayText event.
In specific instances, you may need to change the way cell contents are presented on-screen (for instance, use progress bars to display values). You may also want to allow an end-user to modify cell contents by embedding in-place editors.
Note
When an end-user edits a cell’s value, the changes are not automatically saved to the underlying data source. You need to save these changes manually by handling the PivotGridControl.EditValueChanged event. Otherwise, the changes are lost once the cell loses focus.
Cell Editors Overview
You can assign in-place editors to cells to:
- replace cell values in display mode (when editing is inactive);
- allow an end-user to edit cells.
Pivot Grid Control cells can embed editors from the XtraEditors Library (descendants of the BaseEdit class). These include: ButtonEdit, DateEdit, CalcEdit, ProgressBarControl, LookUpEdit, etc.
The image below shows a sample PivotGridControl with different editors assigned to data fields. The CalcEdit and ProgressBarControl controls are used for in-place editing within cells corresponding to the first and second data fields (Extended Price and Percent of Column).
Note
Third-party editors cannot be embedded into cells.
Providing In-place Editors
Follow the steps below to assign in-place editors to cells:
- Create a repository item - a RepositoryItem class descendant that stores properties and events related to a specific editor. It contains all the information required for creating an editor.
- Add this item to the EditorContainer.RepositoryItems collection that contains editors the current control can use.
Assign the created repository item to the PivotGrid control using one of the approaches below.
Assigning Editors to Data Field’s Cells
The most common approach is assigning an in-place editor to a particular data field, which results in all corresponding cells using that editor.
Assigning Editors to Individual Cells
The second approach is assigning (or overriding) in-place editors for particular cells, for instance, display value cells using the ProgressBar editor and total cells using the SpinEdit editor.
Assigning Editors for In-place Editing
This topic demonstrates how to use different editors to present and edit cell values.
The editor binding methods can be used in various combinations. This means you can provide editors for a data field and then override editor assignments for the particular cells of this field.
See Preventing Editors from Being Activated to learn how to prevent end-users from activating editors.
Saving Changes
When an end-user edits a cell’s value, the changes are not automatically saved to the underlying data source. You need to save these changes manually by handling the PivotGridControl.EditValueChanged event. Otherwise, the changes are lost once the cell loses focus.
Examples
- Assign In-Place Editors to Different Types of Cells
- Override the In-Place Cell Editor
- Edit Pivot Grid Cells in the UI and Store Cell Values in the Underlying Data Source