This is a migrated thread and some comments may be shown as answers.

Grid / Editing custom editor example question

1 Answer 139 Views
Grid
This is a migrated thread and some comments may be shown as answers.
AndyP
Top achievements
Rank 1
AndyP asked on 02 Mar 2017, 10:21 AM
This examples http://demos.telerik.com/aspnet-mvc/grid/editing-custom mentions "Html.Kendo().DropDownListFor()" but the actual razor markup does not use this helper. Can someone show how to correctly use the drop down within the grid in MVC ?

1 Answer, 1 is accepted

Sort by
0
Dimiter Topalov
Telerik team
answered on 03 Mar 2017, 04:42 PM
Hi AndyP,

The Html.Kendo().DropDownListFor() helper can be found in the ClientCategory.cshtml file, in the EditorTemplates folder.

The described custom editor functionality is achieved by following the steps in the following article from our documentation:

http://docs.telerik.com/aspnet-mvc/helpers/grid/templating/editor-templates#configuration-Create

The demo, and all associated files (View, Controllers, EditorTemplates, and class definitions) are also available in the sample application, coming with your installation package:

http://docs.telerik.com/aspnet-mvc/introduction#sample-application

Alternatively, you can use the following syntax:

// Grid configuration in the .cshtml file
...
columns.Bound(p => p.Category).ClientTemplate("#=Category.CategoryName#").EditorTemplateName("ClientCategory").Width(180);
...

// ClientCategory.cshtml in the EditorTemplates folder
@model Kendo.Mvc.Examples.Models.CategoryViewModel
  
@(Html.Kendo().DropDownListFor(m => m)
        .DataValueField("CategoryID")
        .DataTextField("CategoryName")
        .BindTo((System.Collections.IEnumerable)ViewData["categories"])
)

http://docs.telerik.com/aspnet-mvc/api/Kendo.Mvc.UI.Fluent/GridBoundColumnBuilder#methods-EditorTemplateName(System.String)

I hope this helps.

Regards,
Dimiter Topalov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
AndyP
Top achievements
Rank 1
Answers by
Dimiter Topalov
Telerik team
Share this question
or