1

これは私のコードです:

@(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()
      )

したがって、クライアントテンプレートをメイングリッドのリソースタイプに追加すると、すべてが正常に機能しますが、作成ボタンを押すと通知されます

"Uncaught ReferenceError: ResourceType is not defined "

clienttemplate を削除すると、グリッドのドロップダウン リストが機能しなくなります。

4

0 に答える 0