# TreeList Inline Editing

Inline TreeList editing lets users modify all values on a TreeList row. The edit process starts and ends with clicking of command buttons on the respective row. Inline editing can be more intuitive for beginner users, compared to in-cell editing.

> Make sure to read the [TreeList CRUD Operations](https://www.telerik.com/blazor-ui/documentation/components/treelist/editing/overview) article first.

## Basics

To use inline TreeList editing, [set the TreeList `EditMode` parameter to `TreeListEditMode.Inline`](https://www.telerik.com/blazor-ui/documentation/components/treelist/editing/overview#edit-modes). During inline editing, only one table row is in edit mode at a time. Users can:

* Press **Tab** or **Shift** + **Tab** to focus the next or previous editable cell.
* Click the **Save** command button or press **Enter** to confirm the current row changes and exit edit mode.
* Click the **Cancel** command button or press **ESC** to cancel the current row changes and exit edit mode.
* Peform another TreeList operation, for example, paging or sorting, to cancel the current edit operation.

## Commands

Inline add, edit, and delete operations use the following [command buttons](https://www.telerik.com/blazor-ui/documentation/components/treelist/editing/overview#commands):

* **Add**
* **Delete**
* **Edit**
* **Save**
* **Cancel**

Without using the above command buttons, the application can:

* [Manage add or edit mode programmatically](https://www.telerik.com/blazor-ui/documentation/knowledge-base/grid-add-edit-state) through the [TreeList state](https://www.telerik.com/blazor-ui/documentation/components/treelist/state).
* Modify data items directly in the TreeList data source. [Rebind the TreeList](https://www.telerik.com/blazor-ui/documentation/common-features/data-binding/overview#refresh-data) afterwards.

In inline edit mode, the TreeList commands execute row by row and the corresponding [TreeList events](https://www.telerik.com/blazor-ui/documentation/components/treelist/editing/overview#events) also fire row by row. This is similar to [popup editing](https://www.telerik.com/blazor-ui/documentation/components/treelist/editing/popup) and unlike [in-cell editing](https://www.telerik.com/blazor-ui/documentation/components/treelist/editing/incell), where commands and events relate to cells.

When validation is not satisfied, clicking the **Save**, **Delete** or **Add** command buttons has no effect, but users can still navigate between all input components in the row to complete the editing.

## New Row Position

You can control whether a newly added item appears at the top or bottom of the TreeList. Use the `NewRowPosition` parameter to specify the position. This parameter does not affect Popup edit mode, which always displays a dialog for new items.

The `NewRowPosition` parameter accepts values from the `TreeListNewRowPosition` enum:

* `Top` (default)—Inserts the new item at the top of the view.
* `Bottom`—Inserts the new item at the bottom of the view.

## Integration with Other Features

Here is how the component behaves when the user tries to use add and edit operations together with other component features. Also check the [common information on this topic for all edit modes](https://www.telerik.com/blazor-ui/documentation/components/treelist/editing/overview#integration-with-other-features).

### Add, Edit

This section explains what happens when the component is already in add or edit mode, and the user tries to add or edit another row.

* If the validation is not satisfied, the component blocks the user action until they complete or cancel the current add or edit operation.
* If the validation is satisfied, then editing aborts and the component fires `OnCancel`.

### Delete, Filter, Group, Page, Search, Sort

If the component is already in add or edit mode, and the user tries to perform another data operation, then editing aborts and the component fires `OnCancel`.

Deleting items that are currently in edit mode [fires `OnDelete` with a cloned data item instance](https://www.telerik.com/blazor-ui/documentation/components/treelist/editing/overview#delete-operations).

## Example

The example below shows how to:

* Implement inline TreeList CRUD operations with the minimal required number of events.
* Bind an editable TreeList to [flat data](https://www.telerik.com/blazor-ui/documentation/components/treelist/data-binding/flat-data). Check the \[popup editing example] for an implementation with [hierarchical data](https://www.telerik.com/blazor-ui/documentation/components/treelist/data-binding/hierarchical-data).
* Use the `OnCreate`, `OnDelete` and `OnUpdate` events to make changes to the TreeList data source.
* Query the data service and reload the TreeList `Data` when the create, delete, or update operation is complete.
* Use `DataAnnotations` validation for some model class properties.
* Define the `Id` column as non-editable.
* Customize the `Notes` column editor without using an `EditorTemplate`.
* Confirm **Delete** commands with the built-in TreeList Dialog. You can also [intercept item deletion with a separate Dialog or a custom popup](https://www.telerik.com/blazor-ui/documentation/knowledge-base/grid-customize-delete-confirmation-dialog).
* Override the `Equals()` method of the TreeList model class to prevent collapsing of updated items.
* Toggle the `HasChildren` property value of parent items when they lose all their children or gain their first child item.
* Delete all children of a deleted parent item.

> caption TreeList inline editing

<demo metaUrl="client/treelist/editing/inline/example-1/" height="720"></demo>

## See Also

* [Live Demo: TreeList Inline Editing](https://demos.telerik.com/blazor-ui/treelist/editing-inline)
* [TreeList Editor Template](https://www.telerik.com/blazor-ui/documentation/components/treelist/templates/editor)
* [Start and End Editing through the TreeList State](https://www.telerik.com/blazor-ui/documentation/knowledge-base/grid-add-edit-state)
