Kendo MultiSelect不会填充绑定值

时间:2014-11-11 21:17:18

标签: kendo-ui telerik kendo-asp.net-mvc telerik-mvc kendo-multiselect

我有MultiSelect属于Kendo ListView EditorTemplates。当我想提交选定的MultiSelect值时,我获得了所选项目列表,但所有项目都填充了0值。我无法获得所选项目的正确值。

这是我的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 }))
  ))

这是我的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>

修改: ViewBag.Fields包含c2cFieldList模型的列表,我希望在提交视图时获得FieldID的列表。

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

任何建议都会有所帮助。

0 个答案:

没有答案