Version

Editing Data

Please note that this control has been retired and is now obsolete to the XamDataGrid control, and as such, we recommend migrating to that control. It will not be receiving any new features, bug fixes, or support going forward. For help or questions on migrating your codebase to the XamDataGrid, please contact support.

The xamGrid™ control allows your end users to edit data in its rows. You can allow your end users to edit data in two ways: enter edit mode for the entire row or on a cell-by-cell basis. The control supports data that implements the IEditableObject interface and raises the BeginEdit, CancelEdit and EndEdit methods at their appropriate times. The EditingSettings object provides you with many options when it comes to editing in xamGrid. The control’s editing behavior, events, methods, and settings are described below.

Editing Behavior

Editing of xamGrid’s data can only occur when your end user enters edit mode. This applies to checkbox columns as well - a checkbox is only editable when its cell is in edit mode.

To allow editing for a template column, use the TemplateColumn object’s EditorTemplate property to set a custom editor. For more information about editing a template column, see Editing Data in a Template Column.

To provide your own value converter, set a column’s EditorValueConverter and EditorValueConverterParameter properties.

Keyboard Editing Behavior

  • Enter - Exits edit mode and commits changes.

  • Up Arrow - Exits edit mode, commits changes, and moves to previous row if there is one.

  • Down Arrow - Exits edit mode, commits changes, and moves to next row if there is one.

  • Left Arrow - Exits edit mode, commits changes, and moves to previous cell if there is one. Retains edit mode if edit mode is on entire row and the cell moved to is not on a new row.

  • Right Arrow - Exits edit mode, commits changes, and moves to next cell if there is one. Retains edit mode if edit mode is on entire row and the cell moved to is not on a new row.

  • Tab - Moves to next cell and commits changes. Retains edit mode if edit mode is on entire row and the cell moved to is not on a new row.

  • Escape key - exits edit mode and cancels changes.

Note
Note:

An editor has priority in edit mode. Therefore, if an editor handles a certain keystroke, it replaces the behavior implemented by xamGrid.

Mouse Editing Behavior

  • Hover a cell - if AllowEditing is set to Hover commits change on previously edited cell if there is such and enters edit mode.

  • Single click on a cell - if IsMouseActionEditingEnabled is set to SingleClick commits change on previously edited cell if there is such and enters edit mode.

  • Double click on a cell - if IsMouseActionEditingEnabled is set to DoubleClick commits change on previously edited cell if there is such and enters edit mode.

  • Perform a click outside the xamGrid - commits change on previously edited cell if there is such.

Note
Note:

When entering edit mode the xamGrid will start editing a single cell or all cells in a rows , depending on the value of the AllowEditing property, which is discussed later in this topic.

When AllowEditingValidation is True on a column, exiting edit mode requires that data is valid; i.e, the data your end user enters does not throw an exception. Otherwise, the Escape key needs to be pressed to cancel the change and exit edit mode. For more information on data validation when editing, see Validating Data.

Scrolling with the horizontal scrollbar will not exit edit mode when AllowEditing is set to Row; scrolling with the vertical scrollbar exits both Row and Cell editing.

Editing Events

The xamGrid control provides various editing events for you to implement custom behavior. The following lists the editing events.

Note
Note:

All of the "ing" events, such as CellEnteringEditMode, are cancellable.

Editing Methods

The following is a list of editing methods xamGrid provides to enter and exit edit mode from code behind.

Editing Settings

The EditingSettings object provides you with a list of properties to set up editing for xamGrid.

  • AllowEditing – Set the behavior of xamGrid when the end user tries to enter edit mode on a cell. The following EditingType enumeration values are available: Cell, Row, Hover or None.

  • IsEnterKeyEditingEnabled – Allows entering edit mode with the Enter key.

  • IsF2EditingEnabled – Allows entering edit mode with F2 key.

  • IsMouseActionEditingEnabled – Allows entering edit mode with a single or double click.

  • IsOnCellActiveEditingEnabled – Allows entering edit mode when a cell becomes active, for example with the Tab key.

When you set the AllowEditing property to Hover, the grid will enter in edit mode when you just hover it with the mouse. Use the xamGrid’s RowHover property to specify whether a single cell or the whole row should enter edit mode.

Aside from setting editing options on the entire control, you can also set options on individual ColumnLayout objects. Further, each individual EditableColumn object exposes an IsReadonly property to enable/disable editing on a column basis. The following code shows you how to enable editing on a row-by-row basis for the top level data and a cell-by-cell basis for the nested data.

In XAML:

<ig:XamGrid x:Name="xamGrid1">
    <ig:XamGrid.EditingSettings>
        <ig:EditingSettings AllowEditing="Row" />
    </ig:XamGrid.EditingSettings>
    <ig:XamGrid.Columns>
        <ig:ColumnLayout Key="Products">
            <ig:ColumnLayout.EditingSettings >
                <ig:EditingSettingsOverride AllowEditing="Cell" />
            </ig:ColumnLayout.EditingSettings >
        </ig:ColumnLayout>
    </ig:XamGrid.Columns>
</ig:XamGrid>

In Visual Basic:

Me.xamGrid1.EditingSettings.AllowEditing = EditingType.Row
Me.xamGrid1.Columns.ColumnLayouts.FromKey("Products").EditingSettings.AllowEditing = EditingType.Cell

In C#:

this.xamGrid1.EditingSettings.AllowEditing = EditingType.Row;
this.xamGrid1.ColumnLayouts.FromKey("Products").EditingSettings.AllowEditing = EditingType.Cell;