how to use client template for dropdownList in telerik grid

3.1k views Asked by At

I want to create a dropdownList with unique id in telerik grid. This grid is having in-line edit and add. So, I have created a client template which is working fine with view mode. When clicked on in-line edit button of grid, that dropdownList gets converted into a textbox. So, I want to maintain that dropdownList in edit mode as well. Thanks in advance.

Here is my sample code:

grid = grid
        .Columns(columns =>
        {
            columns.Bound(customField => customField.FieldNumber)
                   .Filterable(false)
                   .Sortable(false)
                   .IncludeInContextMenu(false)
                   .ReadOnly()
                   .Width("60px");
            // here is my client template code
            var dropdownListType = @"&nbsp; <select id='ddlTypeId_<#=CustomMenuId#>'>"
               + "<option value='" + Utilities.GetLabels("CustomMenu_List") + "'>" + Utilities.GetLabels("CustomMenu_List") + "</option>"
               + "<option value='" + Utilities.GetLabels("CustomMenu_Textbox") + "'>" + Utilities.GetLabels("CustomMenu_Textbox") + "</option>";

            columns.Bound(customField => customField.Type)
                .ClientTemplate(dropdownListType)
                .Width("30%")
                .Title("Type");
        });
1

There are 1 answers

1
Mehmet On

Telerik has a demo page for grid. Look here : http://demos.telerik.com/aspnet-mvc/grid/editing-custom I shared image below it is in edit mode and dropdown style.

enter image description here

You can set as parameter your model directly to ClientTemplate method. Look demo for detail pls.