Telerik: Grid-Editor Template

Please see my other Telerik articles.

Customizing an input field within a grid

In this article I’ll demonstrate how to customize a grid’s input field.

Within the grid I have a field: FederalTaxID.

1.Telerik-Grid-EditorTemplate

A requirement was added to enforce this field’s unique format and provide the user a helpful hint as the enter data.

First, I’ll define a partial view to define the layout for this field and use it to provide a helpful hint to the user.

Note: This partial view must be saved in Views\Shared\EditorTemplates.

2.Telerik-Grid-EditorTemplate

Next, within the View Model used by the grid, I’ll update the property with a regular expression which requires the special format and provides a helpful error message if the user violates the requirement.

3.Telerik-Grid-EditorTemplate

Finally, I’ll update the grid to use a template for the editor defined earlier.

4.Telerik-Grid-EditorTemplate

Now, my grid provides the user a helpful hint below the text box regarding the expected format and validates the special format for this field or provides a helpful error message.

5.Telerik-Grid-EditorTemplate