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

Dropdown in Grid column

1 Answer 314 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stany
Top achievements
Rank 1
Stany asked on 19 Jun 2012, 03:18 PM
I managed to get a dropdown in a grid column. But I have no clue on how to set the selected value, and when I save it doesn't save my selected value.

The grid

@using Perseus.Areas.Communication.Models
@using Perseus.Common.BusinessEntities;


<div class="gridWrapper">
    @(Html.Kendo().Grid<CommunicationModel>()
        .Name("grid")
        .Columns(colums =>
        {
            colums.Bound(o => o.communication_type_id)
                .EditorTemplateName("_communicationDropDown")
                .ClientTemplate("#: communication_type #")
                .Title("Type")
                .Width(180);
            colums.Bound(o => o.sequence).Width(180);
            colums.Bound(o => o.remarks);
            colums.Command(command => command.Edit()).Width(50);
        })
        .Pageable()
        .Sortable()
        .Filterable()
        .Groupable()
        .Editable(edit => edit.Mode(GridEditMode.InLine))
        .DataSource(dataSource => dataSource
            .Ajax()
            .ServerOperation(false)
            .Model(model => model.Id(o => o.communication_id))
                .Read(read => read.Action("AjaxBinding", "Communication", new { id = @ViewBag.addressId }))
                .Update(update => update.Action("Update", "Communication"))
            .Sort(sort => { sort.Add(o => o.sequence).Ascending(); })
            .PageSize(20)
        )
    )
</div>


The EditorTemplate "_communicationDropDown

@model Perseus.Areas.Communication.Models.CommunicationModel


@(Html.Kendo().DropDownListFor(c => c.communication_type_id)
        .Name("DropDownListCommunication")
            .DataTextField("description1")
            .DataValueField("communication_type_id")
            .BindTo(ViewBag.CommunicationTypes))

1 Answer, 1 is accepted

Sort by
0
Pechka
Top achievements
Rank 1
answered on 21 Jun 2012, 01:39 PM
Yo

The Name of the DDL should be the same as the name of your property (i.e. "communication_type_id")
If using DropDownFor I think you even do not need to specify a Name for the
Tags
Grid
Asked by
Stany
Top achievements
Rank 1
Answers by
Pechka
Top achievements
Rank 1
Share this question
or