Edit Cell

 
Courtesy Title First Name Last Name Title Home Phone City Birth Date Hire Date
Ms.NancyDavolioSales Representative(206) 555-9857Seattle12/8/19785/1/2005
Dr.AndrewFullerVice President, Sales(206) 555-9482Tacoma2/19/19658/14/1992
Ms.JanetLeverlingSales Representative(206) 555-3412Kirkland8/30/19854/1/2002
Mrs.MargaretPeacockSales Representative(206) 555-8122Redmond9/19/19735/3/1993
Mr.StevenBuchananSales Manager(71) 555-4848London3/4/195510/17/1993
Mr.MichaelSuyamaSales Representative(71) 555-7773London7/2/198110/17/1999
Mr.RobertKingSales Representative(71) 555-5598London5/29/19601/2/1994
Ms.LauraCallahanInside Sales Coordinator(206) 555-1189Seattle1/9/19853/5/2004
Ms.AnneDodsworthSales Representative(71) 555-4444London1/27/198011/15/2004
Data grid with 9 rows and 9 columns
0 rows are selected

When EditCell mode is used, the DevExpress Blazor Grid displays an in-place editor when a user clicks a data cell. This allows users to edit the current cell value and activate editors for other cells within the same row. When focus moves to a different row, the control validates user input and saves changes.

To enable cell editing:

  1. Set the EditMode property to EditCell.
  2. If your data object has a primary key, assign it to the KeyFieldName or KeyFieldNames property. The Grid uses field values to compare and identify data items. If you do not specify these properties, the Grid uses standard .NET value equality comparison to identify data items.
  3. Handle the following events to make final data changes, check access permissions, post changes to the underlying data source, and reload Grid data:
    • EditModelSaving — Fires when a user saves the edited row and validation passes.
    • DataItemDeleting — Fires when a user confirms the delete operation in the delete confirmation dialog. To enable the delete operation, implement step 4.
  4. (Optional) Declare a DxGridCommandColumn object in the Columns template to allow users to create and delete data rows. In addition to predefined New and Delete buttons, this column displays Edit, Save, and Cancel command buttons that are not used in this mode. Disable EditButtonVisible, CancelButtonVisible, and SaveButtonVisible properties to hide these buttons.
  5. (Optional) Handle the CustomizeEditModel event to initialize an edit model for new data rows.

The Grid control supports keyboard shortcuts that speed up navigation and editing. This demo showcases some of the most common shortcuts:

Enter / Shift+Enter

Opens an in-place editor for the focused cell (if not already open).

If an in-place editor is open, changes are applied, and the editor is closed. Focus can then move to the next/previous cell depending on the EnterKeyDirection property. Select a value from the Focus Moves on Enter box to see how behavior changes:

  • No (GridEnterKeyDirection.None): Validate the cell value and close the editor.
  • Up/Down (GridEnterKeyDirection.Column): Move focus to the cell below/above (in the same column).
  • Left/Right (GridEnterKeyDirection.Row): Move focus to the next/previous cell in the same row.

Note: Shift+Enter moves focus in the opposite direction.

Esc

Hides the in-place editor and discards changes made in that cell.

If the in-place editor is hidden, discards all changes made in the row and cancels row editing.

Tab / Shift+Tab

Hides the editor, focuses the next/previous data cell, and displays an editor in the newly focused cell.

Start typing in a focused cell

When the EditOnKeyPress property is enabled, users can start editing a cell by typing a value within it. The editor opens automatically and accepts entered characters.

Select the Edit On Key Press option to try it out.

For additional information on how you can enable data editing and use edit-related options, refer to the following help topic.