# ASP.NET Core PropertyGrid Overview

The Telerik UI PropertyGrid TagHelper and HtmlHelper for ASP.NET Core are server-side wrappers for the Kendo UI PropertyGrid widget.

The PropertyGrid allows you to display and edit properties and attributes of objects. You can bind the component to a Model, edit its nested properties, specify the desired editor and customized template, group, sort, search, or navigate through the data or export it in Excel and PDF.

* [Demo page for the PropertyGrid HtmlHelper](https://demos.telerik.com/aspnet-core/propertygrid)

* [Demo page for the PropertyGrid TagHelper](https://demos.telerik.com/aspnet-core/propertygrid)

## Initializing the PropertyGrid

The following example demonstrates how to define the PropertyGrid.

```Razor HtmlHelper
    @model PropertyViewModel

    @(Html.Kendo().PropertyGrid<PropertyViewModel>()
        .Name("propertyGrid")
        .Model(Model)
        .Columns(columns => 
        {
            columns.FieldColumn(fieldCol => fieldCol.Width(200));
            columns.ValueColumn(valueCol => valueCol.Width(250));
        })
    )
```

```Razor TagHelper
    @addTagHelper *, Kendo.Mvc
    @model PropertyViewModel

    <kendo-propertygrid name="propertyGrid" model="@Model">
        <columns>
            <field-column width="200" />
            <value-column width="250" />
        </columns>
    </kendo-propertygrid>
```

```C# Model
    using System.ComponentModel.DataAnnotations;

    public class PropertyViewModel
    {
        [Display(GroupName = "Size", Description = "Control the width of the element.")]
        public int Width { get; set; }

        [Display(GroupName = "Size", Description = "Control the height of the element.")]
        public int Height { get; set; }

        [Display(GroupName = "Alignment", Description = "Add space around the element.")]
        public int Margin { get; set; }

        [Display(GroupName = "Alignment", Description = "Add space around the content of the element.")]
        public int Padding { get; set; }
    }
```

```C# Controller
    public ActionResult Index()
    {
        return View(new PropertyViewModel()
        {
            Width = 500,
            Height = 300,
            Margin = 20,
            Padding = 50
        });
    }
```

## Basic Configuration

The PropertyGrid provides a variety of options for the items configuration, toolbar, context menu, and appearance options like width, height, resizability, and more. The following example demonstrates the basic configuration of the PropertyGrid.

```Razor HtmlHelper
    @model PropertyViewModel

    @(Html.Kendo().PropertyGrid<PropertyViewModel>()
        .Name("propertyGrid")
        .Model(Model)
        .EditMode(true)
        .ContextMenu(true)
        .Columns(columns => 
        {
            columns.FieldColumn(fieldCol => fieldCol.Width(200));
            columns.ValueColumn(valueCol => valueCol.Width(250));
        })
        .Items(items =>
        {
             
            items.Add().Field(f => f.Width)
                .Editor(editor => editor.NumericTextBox().Step(1).Min(1).Max(1000));
            items.Add().Field(f => f.Height)
                .Editor(editor => editor.NumericTextBox().Step(1).Min(1).Max(1000));
            items.Add().Field(f => f.Icon)
                .Editor(editor => editor
                    .DropDownList()
                    .DataTextField("Text")
                    .DataValueField("Value")
                    .BindTo(new List<SelectListItem>() {
                        new SelectListItem() {
                            Text = "search", Value = "search"
                        },
                        new SelectListItem() {
                            Text = "user", Value = "user"
                        },
                        new SelectListItem() {
                            Text = "folder", Value = "folder"
                        }
                    }));
        })
    )
```

```Razor TagHelper
    @addTagHelper *, Kendo.Mvc
    @model PropertyViewModel

    @{
        var icons = new List<SelectListItem>() {
            new SelectListItem() {
                Text = "search", Value = "search"
            },
            new SelectListItem() {
                Text = "user", Value = "user"
            },
            new SelectListItem() {
                Text = "folder", Value = "folder"
            }
        };
    }

    <kendo-propertygrid name="propertyGrid" model="@Model" edit-mode="true">
        <context-menu enabled="true"></context-menu>
        <columns>
            <field-column width="200" />
            <value-column width="250" />
        </columns>
        <property-grid-items>
            <property-grid-item field="Width">
                <numerictextbox-editor min="1" max="1000" step="1"></numerictextbox-editor>
            </property-grid-item>
            <property-grid-item field="Height">
                <numerictextbox-editor min="1" max="1000" step="1"></numerictextbox-editor>
            </property-grid-item>
            <property-grid-item field="Icon">
                <dropdownlist-editor datatextfield="Text" datavaluefield="Value" bind-to="icons"></dropdownlist-editor>
            </property-grid-item>
        </property-grid-items>
    </kendo-propertygrid>
```

```C# Model
    using System.ComponentModel.DataAnnotations;

    public class PropertyViewModel
    {
        [Display(GroupName = "Size", Description = "Control the width of the element.")]
        public int Width { get; set; }

        [Display(GroupName = "Size", Description = "Control the height of the element.")]
        public int Height { get; set; }

        [Display(GroupName = "UI", Description = "Defines a name of an icon.")]
        public string Icon { get; set; }
    }
```

```C# Controller
    public ActionResult Index()
    {
        return View(new PropertyViewModel()
        {
            Width = 500,
            Height = 300,
            icon = "search"
        });
    }
```

## Toolbar

The [`Toolbar()`](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/propertygridtoolbarfactory) configuration option of the PropertyGrid allows you to add command buttons and allow the user to invoke built-in PropertyGrid functionalities. You can also define custom commands or use templates to customize the Toolbar of the Telerik UI for ASP.NET Core PropertyGrid.

### Built-In Commands

You can configure the Toolbar and include any of the built-in commands:

```Razor HtmlHelper
    .Toolbar(t => 
    {
        t.Group();
        t.Separator();
        t.Details();
        t.Search();
        t.Spacer();
        t.Sort();
    })
```

```Razor TagHelper
        <toolbar>
            <property-grid-toolbar-button name="group"></property-grid-toolbar-button>
            <property-grid-toolbar-button name="details"></property-grid-toolbar-button>
            <property-grid-toolbar-button name="search"></property-grid-toolbar-button>
            <property-grid-toolbar-button name="sort"></property-grid-toolbar-button>
            <property-grid-toolbar-button name="seperator"  type="separator"></property-grid-toolbar-button>
            <property-grid-toolbar-button name="spacer" type="spacer"></property-grid-toolbar-button>
        </toolbar>
```

Starting with version 2025 Q2, an alternative way to configure the tools of the PropertyGrid HtmlHelper is to use the `Items()` configuration of the Toolbar:

```Razor HtmlHelper
    .Toolbar(toolbar =>toolbar
        .Items(item=>{
            item.Group();
            item.Separator();
            item.Details();
            item.Search();
            item.Spacer();
            item.Sort();
        })
        .Overflow(overflow => overflow
            .Mode(ToolBarOverflowMode.Scroll)
            .ScrollButtons(ScrollButtonsType.Visible)
            .ScrollButtonsPosition(ScrollButtonsPositionType.Split)
        )
    )
```

| Command   | Description                                                                  |
| --------- | ---------------------------------------------------------------------------- |
| Group     | Adds a toggle button to show the items in Groups or a List.                  |
| Details   | Adds an info button for additional details.                                  |
| Sort      | Adds a DropDownList to control the order of the items.                       |
| Search    | Adds a built-in Search input for the PropertyGrid.                           |
| Spacer    | Moves the tools that are declared after it to the right side of the Toolbar. |
| Separator | Acts as a delimiter between the Toolbar commands.                            |

#### Overview

The built-in Toolbar provides properties for customizing its overflow behavior and appearance.

The following example demonstrates how to modify the default overflow settings of the Toolbar through the `Oveflow()` configuration.

```Razor
    @(Html.Kendo().PropertyGrid<PropertyViewModel>()
        .Name("propertyGrid")
        .Toolbar(t => t.Items(item =>
        {
            item.Spacer();
            item.Search();
        })
        .Overflow(o => o
            .Mode(ToolBarOverflowMode.Scroll)
            .ScrollButtons(ScrollButtonsType.Auto)
            .ScrollButtonsPosition(ScrollButtonsPositionType.Start)
            .ScrollDistance(50))
        )
            ... // Additional configuration.
         )
```

```Razor TagHelper
    <kendo-propertygrid name="propertyGrid">
        <toolbar>
            <property-grid-toolbar-button name="spacer" type="spacer"></property-grid-toolbar-button>
            <property-grid-toolbar-button name="search"></property-grid-toolbar-button>
            <overflow mode="ToolBarOverflowMode.Scroll" scroll-buttons="ScrollButtonsType.Auto" scroll-buttons-position="ScrollButtonsPositionType.Start" scroll-distance="50" />
        </toolbar>
    
</kendo-propertygrid>
```

For more information on the available overflow options, refer to the [Appearance documentation of the ToolBar component](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/navigation/toolbar/appearance).

## Functionality and Features

* [Columns](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/data-management/propertygrid/columns)—The PropertyGrid displays fields and values in columns.
* [Items](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/data-management/propertygrid/items)—The configuration of the PropertyGrid items allows you to customize their appearance and behavior.
* [Templates](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/data-management/propertygrid/templates)—The available templates allow you to control the rendering of the items and toolbar.
* [Events](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/data-management/propertygrid/events)—The component emits a variety of events that allow you to implement custom functionality.
* [Accessibility](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/data-management/propertygrid/accessibility/overview)—The PropertyGrid is accessible for screen readers, supports WAI-ARIA attributes, and delivers [keyboard shortcuts](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/data-management/propertygrid/accessibility/keyboard-navigation) for faster navigation.

## Next Steps

* [Getting Started with the PropertyGrid](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/data-management/propertygrid/getting-started)

* [Basic Usage of the PropertyGrid HtmlHelper for ASP.NET Core (Demo)](https://demos.telerik.com/aspnet-core/propertygrid)

* [Basic Usage of the PropertyGrid TagHelper for ASP.NET Core (Demo)](https://demos.telerik.com/aspnet-core/propertygrid)

## See Also

* [Using the API of the PropertyGrid for ASP.NET Core (Demo)](https://demos.telerik.com/aspnet-core/propertygrid/api)

* [Server-Side API of the PropertyGrid HtmlHelper](https://www.telerik.com/aspnet-core-ui/documentation/api/propertygrid)

* [Server-Side API of the PropertyGrid TagHelper](https://www.telerik.com/aspnet-core-ui/documentation/api/taghelpers/propertygrid)

* [Client-Side API of the PropertyGrid](https://docs.telerik.com/kendo-ui/api/ui/propertygrid)
