加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – 使用编辑器下拉列表值更新Kendo网格

发布时间:2020-12-16 07:12:48 所属栏目:asp.Net 来源:网络整理
导读:我有一个剑道网格设置如下: @(Html.Kendo().GridParticipatingDentalEE().Name("DentalEE").Columns(columns ={ columns.Bound(p = p.State).Title("State").Width(150).EditorTemplateName("State"); columns.Bound(p = p.Count).Title("Count").Width(150
我有一个剑道网格设置如下:

@(Html.Kendo().Grid<ParticipatingDentalEE>()
.Name("DentalEE")
.Columns(columns =>
{
    columns.Bound(p => p.State).Title("State").Width(150).EditorTemplateName("State");
    columns.Bound(p => p.Count).Title("Count").Width(150);
    columns.Command(c => { c.Edit(); c.Destroy(); });
})
.DataSource(dataSource => dataSource
    .Ajax()           
    .Model(m => {
        m.Id(p => p.State);
        m.Field(p => p.State).Editable(true);
        m.Field(p => p.Count).Editable(true).DefaultValue("");
    })
    .Create(update => update.Action("EditingInline_Create","Dental"))
    .Read(read => read.Action("EditingInline_Read","Dental"))
    .Update(update => update.Action("EditingInline_Update","Dental"))
    .Destroy(update => update.Action("EditingInline_Destroy","Dental"))
)
//.Scrollable()
//.Sortable()
.Editable(e => e.Mode(GridEditMode.InLine))

)

“状态”列包含一个下拉模板,如下所示:

@(Html.Kendo().DropDownList()
    .Name("States") // Name of the widget should be the same as the name of the property
    .DataValueField("CODE") // The value of the dropdown is taken from the EmployeeID property
    .DataTextField("NAME") // The text of the items is taken from the EmployeeName property
    .BindTo((System.Collections.IEnumerable)ViewData["States"]) // A list of all employees which is populated in the controller
)

当我编辑或创建项目时,我的下拉列表正确显示,但是当我保存项目时,下拉值不会保留在网格中.为了做到这一点,我还需要设置其他东西吗?

解决方法

正如你在自己的评论中所说,

.Name("States") // Name of the widget should be the same as the name of the property

也就是说,它必须与列的名称匹配,列名称是“State”而不是“States”.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读