Kendo MultiSelect does not populate bound values

816 views Asked by At

I have a MultiSelect belongs to Kendo ListView EditorTemplates. When I want to submit selected MultiSelect values, I got list of items selected, but all populated with 0 value. I cant get correct value of selected items.

Here is my ListView:

@(Html.Kendo().ListView<esCMS.Modules.C2C.Domain.c2cFieldRangeList>()
  .Name("listView")
  .TagName("div")
  .ClientTemplateId("template")
  .DataSource(dataSource => dataSource
      .Model(model => model.Id(x => x.FieldRangeID))
      .PageSize(6)
      .Create(create => create.Action("AddRange", "Field"))
      .Update(update => update.Action("UpdateRange", "Field"))
      .Read(read => read.Action("ReadRange", "Field", new { id = Model.FieldID }))
  ))

And here is my EditorTemplates:

<table>
<tr>
    <td>
        @Html.LabelFor(x => x.RangeValue)
    </td>
    <td>
        :
    </td>
    <td>
        @Html.TextBoxFor(x => x.RangeValue, new { @class = "k-textbox", style = "width:180px" })
        <span data-for="RangeValue" class="k-invalid-msg"></span>
    </td>
</tr>
<tr>
    <td>
        @Html.LabelFor(x => x.SelectedValues)
    </td>
    <td>
        :
    </td>
    <td>
        @(Html.Kendo().MultiSelectFor(x=> x.SelectedValues)
            .HtmlAttributes(new { style = "width:180px" })
            .BindTo(new SelectList(ViewBag.Fields, "FieldID", "Title")))
    </td>
</tr></table>

Edit: ViewBag.Fields contains List of c2cFieldList model and I expect to get List of FieldID when I submit view.

ViewBag.Fields = Entities.c2cField.Where(x => !x.IsGeneral && !x.IsTemp).Select(x => new c2cFieldList { Title = x.Title, FieldID = x.FieldID});

Any advice will be helpful.

0

There are 0 answers