kendo mvc网格层次结构下拉列表创建失败

时间:2014-08-19 13:54:40

标签: kendo-ui kendo-grid kendo-dropdown

这是我的代码:

@(Html.Kendo().Grid<RMS.Admin.ViewModel>()
  .Name("ResourceGrid")
  .Columns(columns =>
  {
      columns.Bound(c => c.ResourceName);
      columns.Bound(c => c.Descritption);
      columns.Bound(c => c.ResourceType).ClientTemplate("#=ResourceType.Name#");
      columns.Bound(c => c.Approved);
      columns.Bound(c => c.IsEnabled);
      columns.Bound(c => c.Data).Width(220);
      columns.Command(command =>
      {
          command.Edit();
          command.Destroy();
      }).Width(172).Title("Edit/Delete");
  })
  .ToolBar(toolbar => toolbar.Create())
  .Editable(editable => editable.Mode(GridEditMode.InLine))
  .Scrollable()
  .Sortable()
      .HtmlAttributes(new { style = "height:800px" })
  .Pageable(pageable => pageable
      .Refresh(true)
      .PageSizes(true)
      .ButtonCount(5))
          .ClientDetailTemplateId("template")
  .DataSource(dataSource => dataSource
      .Ajax()
      .Model(model =>
      {
          model.Id(s => s.ResourceId);
          model.Field(p => p.ResourceType).DefaultValue(ViewData["defResourceType"] as    RMS.Admin.ViewModel.ResourceTypeId);
      })
                .Create(update => update.Action("CreateResource", "Home", new {     resourceTypeId = "#=ResourceType.Id#" }))
              .Read(read => read.Action("ReadResource", "Home"))
            .Update(update => update.Action("SaveSystem", "Home"))
            .Destroy(destroy => destroy.Action("RemoveSystem", "Home"))

    )
        .Events(events => events.DataBound("dataBound"))
  )

    <script id="template" type="text/kendo-tmpl">
        @(Html.Kendo().Grid<RMS.Admin.Metadata>()
         .Name("grid_#=ResourceId#")
         .Columns(columns =>
          {
          columns.Bound(o => o.MetaDataName);
          columns.Bound(o => o.MetaDataDescription);
          columns.Bound(o => o.LanguageCode);
          columns.Command(command =>
          {
              command.Edit();
              command.Destroy();
          }).Width(172).Title("Edit/Delete");
      })
               .HtmlAttributes(new { style = "height:500px" })
               .ToolBar(toolbar => toolbar.Create())
          .Editable(editable => editable.Mode(GridEditMode.InLine))

      .DataSource(dataSource => dataSource
                          .Ajax()
                          .PageSize(10)
                            .Model(model => model.Id(s => s.MetaDataId))
                          .Read(read => read.Action("GetMetaDataByResourceId", "Home", new { id = "#=ResourceId#" }))
                          .Create(update => update.Action("CreateMetaData", "Home", new { id = "#=ResourceId#" }))
                          .Update(update => update.Action("SaveSystem", "Home"))
                            .Destroy(destroy => destroy.Action("RemoveSystem", "Home"))
      )
      .Scrollable()
      .Sortable()
      .ToClientTemplate()
      )

所以当我在主网格上将resourcetemplate添加到resourcetype时,一切正常,但是当我按下创建按钮时告诉我

"Uncaught ReferenceError: ResourceType is not defined "

如果我把客户模板带走,网格中的下拉列表就无法工作。

0 个答案:

没有答案