【问题标题】:Kendo Editor Templates (Grid)剑道编辑器模板(网格)
【发布时间】:2013-03-25 15:50:40
【问题描述】:

我正在尝试使用Editor Templates 填充一个下拉列表以在我的剑道网格中使用。

我的 StatesEditor.cshtml 包含:

@(Html.Kendo().DropDownList()
.Name("State") 
.DataValueField("StateID") 
.DataTextField("ShortName") 
.BindTo((System.Collections.IEnumerable)ViewData["states"]))

在我的控制器中,我有:

public ActionResult Index()
    {
        var db = new ACoreEntities();
        db.Configuration.ProxyCreationEnabled = false;
        var states = db.StateLookups;

        var stateList = states.Select(state => state.ShortName);

        ViewData["states"] = stateList;


        return View("~/Views/System/PMarkup/Index.cshtml");
    }

在我的实际网格中,当我单击行的“编辑”按钮时,我会得到一个包含 51 个“未定义”条目的下拉列表。

【问题讨论】:

标签: kendo-ui kendo-grid


【解决方案1】:

我最终创建了一个状态模型,然后在我的 ActionResult 中我将代码更改为:

ViewData["states"] = new ACoreEntities()
            .StateLookups
            .Select(s => new State
            {
                Id = s.StateID,
                ShortName = s.ShortName
            })
            .OrderBy(s => s.ShortName);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-29
    • 2012-02-14
    相关资源
    最近更新 更多