KendoUI mvc网格,在新记录

时间:2018-05-31 18:04:03

标签: c# asp.net-mvc kendo-ui drag-and-drop kendo-grid

当我点击新记录时,我收到以下错误。

这是错误:

Uncaught ReferenceError: Application is not defined
    at eval (eval at compile (kendo.all.js:194), <anonymous>:3:651)
    at init._rowsHtml (kendo.all.js:60907)
    at init._renderContent (kendo.all.js:61573)
    at init.refresh (kendo.all.js:61411)
    at init.d (jquery.min.js:2)
    at init.trigger (kendo.all.js:124)
    at init._process (kendo.all.js:7327)
    at init._change (kendo.all.js:7287)
    at init.d (jquery.min.js:2)
    at init.trigger (kendo.all.js:124)

this is what i get

这是我的代码:

columns.Bound(c => c.Application).ClientTemplate("#=Application.Name#").EditorTemplateName("ApplicationDropDownEditor");

以下是编辑:

@model Configuration.Web.Models.ApplicationViewModel
@(
            Html.Kendo().DropDownList()
            .Name("Type")
            .DataTextField("Name")
            .DataValueField("Id")
            .DataSource(source =>
            {
                source.Read(read =>
                {
                    read.Action("GetApplications", "Application");
                }
            );
            })
) 

我的班级:

public class ConfigViewModel
{
    public int Id { get; set; }
    [Required]
    public string Key { get; set; }
    [Required]
    public string Value { get; set; }

    [UIHint("ApplicationDropDownEditor")]
    public ApplicationViewModel Application { set; get; }
    public EnvironmentViewModel Environment { set; get; }

    public int? ApplicationId { set; get; }
    public int? EnvironmentId { set; get; }
}

为什么我会收到此错误?

1 个答案:

答案 0 :(得分:0)

添加:

      .Model(model =>
      {
          model.Id(p => p.Id);
          model.Field(field => field.App).DefaultValue(new ApplicationViewModel());
      })

做了这个工作。