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

MVC Grid doesn't show DropDownList column

1 Answer 183 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 23 Jan 2017, 04:13 PM
Hi, 

I have a Grid with a DropDownList column and another TextFields with ClientTemplate. The DropDownList shows a Spinner where I can select the ID of list, and when the field lost focus, shows a text with the text field of list.

I need that when I click on column, show me the DropDownList, not a Spinner.


@(Html.Kendo().Grid(Model.Contacts)
    .Name("Contacts")
    .ToolBar(tools => tools.Create().Text("Agregar nuevo contacto"))
    .Editable(editable => editable.Mode(GridEditMode.InCell).CreateAt(GridInsertRowPosition.Bottom))
    .Columns(columns =>
    {
        columns.Bound(p => p.Name).ClientTemplate("#= Name #" +
            "<input type='hidden' name='Contacts[#= indexContactsBasic(data)#].Name' value='#= Name #' />"
        );
        columns.Bound(p => p.CellPhone).ClientTemplate("#= CellPhone #" +
            "<input type='hidden' name='Contacts[#= indexContactsBasic(data)#].CellPhone' value='#= CellPhone #' />"
        );
        columns.Bound(p => p.Email).ClientTemplate("#= Email #" +
            "<input type='hidden' name='Contacts[#= indexContactsBasic(data)#].Email' value='#= Email #' />"
        );
        columns.Bound(p => p.Occupation).ClientTemplate("#= Occupation #" +
            "<input type='hidden' name='Contacts[#= indexContactsBasic(data)#].Occupation' value='#= Occupation #' />"
        );
        columns.ForeignKey(p => p.ThirdPartyId, ViewBag.EmployeeInformationId as SelectList, "Value", "Text").Width(100);
        columns.Command(command => command.Destroy()).Width(100);
    })
    .DataSource(dataSource => dataSource
        .Ajax()
        .Model(model =>
        {
            model.Id(p => p.Id);
        })
        .ServerOperation(false)
    )
)


Regards,
Daniel

1 Answer, 1 is accepted

Sort by
0
Accepted
Konstantin Dikov
Telerik team
answered on 25 Jan 2017, 08:49 AM
Hi Daniel,

It seems that you are missing the ForeignKey column template. Can you please ensure that you have GridForeignKey.cshtml file with the following content within the Views/Shared/EditorTemplates folder:
@model object
            
@(
 Html.Kendo().DropDownListFor(m => m)       
        .BindTo((SelectList)ViewData[ViewData.TemplateInfo.GetFullHtmlFieldName("") + "_Data"])
)


Best Regards,
Konstantin Dikov
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
Daniel
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or