MVC Grid doesn't show DropDownList column

2 posts, 1 answers
  1. Daniel
    Daniel avatar
    7 posts
    Member since:
    Jul 2016

    Posted 23 Jan 2017 Link to this post

    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
  2. Answer
    Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    2466 posts

    Posted 25 Jan 2017 Link to this post

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