# TreeList Popup Editing

TreeList popup editing allows the app to render a larger form with customizable dimensions and layout. The popup edit mode is also more suitable for mobile devices with small screens. The popup edit form may contain editable fields from hidden columns in the TreeList table.

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

## Basics

To use popup TreeList editing, set the TreeList `EditMode` parameter to `TreeListEditMode.Popup`. During popup editing, only one table row is in edit mode. The user can:

* Press **Tab** or **Shift** + **Tab** to focus the next or previous input component.
* Click the **Save** command button 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.

The popup edit mode can display a [Telerik Validation Summary component](https://www.telerik.com/blazor-ui/documentation/components/validation/summary) if the TreeList model is configured for validation.

## Commands

Popup 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**

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.

Popup edit mode does not use **Save** and **Cancel** command buttons in the [TreeList command column](https://www.telerik.com/blazor-ui/documentation/components/treelist/columns/command). The TreeList renders them automatically in the popup, unless you define a [Buttons Template](https://www.telerik.com/blazor-ui/documentation/components/treelist/templates/popup-buttons-template) or a [Form Template](https://www.telerik.com/blazor-ui/documentation/components/treelist/templates/popup-form-template).

In popup 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.

## Customization

The TreeList exposes options to customize the edit popup and its form. Define the desired configuration in the `TreeListPopupEditSettings` and `TreeListPopupEditFormSettings` tags under the `TreeListSettings` tag.

### Edit Hidden Columns

Starting with version 7.0, the TreeList allows users to edit [hidden columns](https://www.telerik.com/blazor-ui/documentation/components/treelist/columns/visible) by default. To disable editing of a hidden column, set `Editable="false"` to the respective `<TreeListColumn>` tag.

### Popup Settings

The `TreeListPopupEditSettings` nested tag exposes the following parameters to allow popup customization:

<style>
    .article table {
        table-layout: auto;
        word-break: normal;
    }
</style>

| Parameter   | Type     | Description                      |
| ----------- | -------- | -------------------------------- |
| `Class`     | `string` | The CSS class of the edit popup  |
| `Title`     | `string` | The title of the edit popup      |
| `Width`     | `string` | The Width of the edit popup      |
| `MaxWidth`  | `string` | The maximum width of the window  |
| `MinWidth`  | `string` | The minimum width of the window  |
| `Height`    | `string` | The height of edit popup         |
| `MaxHeight` | `string` | The maximum height of the window |
| `MinHeight` | `string` | The minimum height of the window |

> tip The min/max options for the width and height apply to the initial rendering of the window and not browser resizing.

For example, here is [how to set the TreeList popup edit form's title, so that it matches a property value of the edited data item](https://www.telerik.com/blazor-ui/documentation/knowledge-base/grid-popup-edit-title).

### Form Layout

The `TreeListPopupEditFormSettings` nested tag exposes the following parameters to allow edit form customization:

| Parameter       | Type and Default Value               | Description                                                                                                                                               |
| --------------- | ------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ButtonsLayout` | `FormButtonsLayout` <br/> (`End`)    | The horizontal alignment of the buttons. Takes a member of the `FormButtonsLayout` enum: <br/> - `Start` <br/> - `End` <br/> - `Center` <br/> - `Stretch` |
| `Columns`       | `int`                                | The number of the form columns                                                                                                                            |
| `ColumnSpacing` | `int`                                | The column spacing                                                                                                                                        |
| `Orientation`   | `FormOrientation` <br/> (`Vertical`) | The orientation of the form. Takes a member of the `FormOrientation` enum: <br/> - `Horizontal` <br/> - `Vertical`                                        |

> important These settings are not applicable if you are using a [`<FormTemplate>` with a standalone Form component](https://www.telerik.com/blazor-ui/documentation/components/treelist/templates/popup-form-template).

### Form Template

In the `TreeListPopupEditFormSettings`, you can declare a `FormTemplate`. This template enables you to fully customize the appearance and content of the create/edit Popup window in the TreeList. For more information and examples on customizing the TreeList Popup window, refer to the [Popup Form Template](https://www.telerik.com/blazor-ui/documentation/components/treelist/templates/popup-form-template) article.

### Buttons Template

You can specify a `ButtonsTemplate` in the `TreeListPopupEditFormSettings` to customize how the buttons look in the create/edit Popup window of the TreeList. To learn more and see an example of customizing the TreeList Popup buttons, refer to the [Popup Buttons Template](https://www.telerik.com/blazor-ui/documentation/components/treelist/templates/popup-buttons-template) article.

## Example

The example below shows how to:

* Implement popup TreeList CRUD operations with the minimal required number of events.
* Bind an editable TreeList to [hierarchical data](https://www.telerik.com/blazor-ui/documentation/components/treelist/data-binding/hierarchical-data). Check the [inline editing example](https://www.telerik.com/blazor-ui/documentation/components/treelist/editing/inline#example) for an implementation with [flat data](https://www.telerik.com/blazor-ui/documentation/components/treelist/data-binding/flat-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.
* Edit the `Notes` column that is not visible in the TreeList.
* Customize the popup edit form dimensions and layout.

> caption TreeList popup editing

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

## See Also

* [Live Demo: TreeList Popup Editing](https://demos.telerik.com/blazor-ui/treelist/editing-popup)
* [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)
