kendo ui 网格中的下拉列表未选择任何值 [英] dropdownlist in kendo ui grid not selecting any value

查看:14
本文介绍了kendo ui 网格中的下拉列表未选择任何值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我有内联编辑网格,如下所示,我在 CStatusID 列中有下拉列表,但是,在尝试保存到数据库时它没有选择值

Currently i have inline editing grid as in the following, I have drop down list in coloumn CStatusID, However, it does not selected value into when trying to save to database

查看:

@(Html.Kendo().Grid(Model)
    .Name("SList")
        .HtmlAttributes(new { @Style = "align:center; font-size:10px;" })
    .Columns(columns => {
        columns.Bound(p => p.CCID);
        columns.Bound(p => p.CRN);
        columns.Bound(p => p.CStatusID).EditorTemplateName("CStatus
");
        columns.Bound(p => p.DateScheduled).Format("{0:MM/dd/yyyy}");

        columns.Command(commands => commands.Edit()).Width(175);
    })
    //.ToolBar(toolBar => toolBar.Save())
    .Editable(editable => editable.Mode(GridEditMode.InLine))
    .Pageable()
    .Sortable()
    .Scrollable()
    .Navigatable()
    .Selectable(selectable => selectable.Mode(GridSelectionMode.Single)
                                        .Type(GridSelectionType.Row))
    .DataSource(dataSource => dataSource        
        .Ajax()
        .PageSize(10)   
        .Model(model => model.Id(p => p.ConsumerID))
        .Read(read => read.Action("Index", "Management"))
        .Update(update => update.Action("Edit", "Management"))

    )
)

并且我在 shared/Editor 模板下有 CStatus.cshtml:

and I have CStatus.cshtml under shared/Editor template:

@(Html.Kendo().ComboBox()
        .Name("Status")
        //.OptionLabel("Select status")
        .DataValueField("OptID")
        .DataTextField("OptName")
        .BindTo((System.Collections.IEnumerable)ViewData["constStatus"])


)

控制器:

public ActionResult Index()
        {
            PopulateConstStatus();
            return View();
        }

private void PopulateConstStatus()
        {
            ViewData["constStatus"] = new EDEntities().COptions
                       .Select(e => new ConfOptModel
                       {
                           OptionID = e.OptID,
                           OptionName = e.OptName,
                           CTypeID = e.CTypeID
                       })
                       .Where(e => e.CTypeID == 2)
                       .OrderBy(e => e.OptName);
        }

模型

public int OptID { get; set; }
public string OptName { get; set; }

[UIHint("CStatus")]
public COptionsModel COptionsModel { get; set; }

推荐答案

我遵循这个,它很有魅力

I follow this and it work as a charm

http://demos.kendoui.c​​om/web/grid/foreignkeycolumn.html

这篇关于kendo ui 网格中的下拉列表未选择任何值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆