Grid / Editing custom editor example question

2 posts, 0 answers
  1. AndyP
    AndyP avatar
    1 posts
    Member since:
    Nov 2016

    Posted 02 Mar 2017 Link to this post

    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 ?
  2. Dimiter Topalov
    Admin
    Dimiter Topalov avatar
    1282 posts

    Posted 03 Mar 2017 Link to this post

    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.
Back to Top