kendo网格中缺少客户端模板名称

时间:2016-02-09 10:46:59

标签: asp.net-mvc kendo-ui kendo-grid kendo-template

我正在使用带有详细模板的剑道网格

enter image description here

当您编辑SC分配网格时,它将显示ServiceGroup的下拉列表,当您从下拉列表中选择并在网格中移开鼠标时,服务组将变为空。

enter image description here

这是我的主要网格代码

 @(Html.Kendo().Grid<ClientRevenueViewModel>()
.Name("grid")
.Columns(columns =>
{
    columns.Bound(c => c.ClientId)      
    columns.Bound(c => c.Comment).Width(200);
    columns.Command(c => c.Custom("Details").Click("showGraph")).Title("Details").Width(100);

这是我的详细网格代码

 <script id="serviceGroupTemplate" type="text/keno-tmpl">
@(Html.Kendo().TabStrip()
      .Name("tabStrip_#=ClientId#")
      .SelectedIndex(0)
      .Animation(animation => animation.Open(open => open.Fade(FadeDirection.In)))
      .Items(items =>
      {
          items.Add().Text((cYear - 1 + "/" + cYear) + " Service group allocation ").Content(@<text>
                @(Html
                      .Kendo()
                      .Grid<ClientServiceGroupViewModel>()
                      .ToolBar(toolbar =>
                      {
                          toolbar.Create();
                          toolbar.Save().Text("Add service group");
                      })
                      .Editable(e => e.Mode(GridEditMode.InCell))
                      .Name("grid_#=ClientId#") // template expression, to be evaluated in the master context
                      .Columns(columns =>
                      {
                          columns.Bound(o => o.Id).Hidden(true);
                          columns.Bound(o => o.ServiceGroupId)
                              .ClientTemplate("<span style='color:black'>\\#=ServiceGroup\\#</span>")
                              .EditorViewData(new {operatingCenterId = "#=OperatingCenterId#"})
                              .EditorTemplateName("ServiceGroupEditorTemplate")
                              .Title("Service group")
                              .ClientFooterTemplate("Total");
                          columns.Bound(o => o.ServiceGroup).Hidden(true);                           
                      })
                      .DataSource(dataSource => dataSource
                          .Ajax()
                          .Aggregates(ag =>
                          {
                              ag.Add(x => x.Percentage).Sum();
                              ag.Add(x => x.PercentageValue).Sum();
                          })
                          .Events(events => events.Error("error"))
                          .PageSize(5)
                          .Batch(true)
                          .ServerOperation(false)
                          .Read(read => read.Action("GetClientServiceGroup", "ClientAllocatedServiceGroup", new {@clientId = "#=ClientId#"}).Data("getParameters"))
                          .Create(create => create.Action("AddServiceGroupToClient", "ClientAllocatedServiceGroup", new {@clientId = "#=ClientId#", @nextYearBase = "#=NextYearBase#"}).Data("getParameters"))
                          .Update(create => create.Action("UpdateClientServiceGroup", "ClientAllocatedServiceGroup", new {@clientId = "#=ClientId#", @nextYearBase = "#=NextYearBase#" }).Data("getParameters"))
                          .Model(m =>
                          {
                              m.Id(p => p.Id);
                              m.Field(p => p.Id);
                              m.Field(p => p.Percentage);
                              m.Field(p => p.PercentageValue).Editable(false);
                              m.Field(p => p.ServiceGroup);
                              m.Field(p => p.ServiceGroupId);
                          })
                      )
                      .Pageable()
                      .Sortable()
                      //.Events(e => e.Save("checkServiceGroupAllocation"))
                      .ToClientTemplate()

                      )
            </text>
              );

      })
      .ToClientTemplate())

这是我的下拉菜单模板

  @model string
@(Html.Kendo().DropDownListFor(m => m)
.Name("ServiceGroupId")
.DataTextField("Name")
.DataValueField("Id")
.DataSource(source => source.Read(read =>    read.Action("GetServiceGroupForOperatingCenter", "ServiceGroup", new { @operatingCenterId = ViewData["operatingCenterId"] })))
.AutoBind(true)
)

我唯一担心的是,从下拉列表中选择服务组后服务组变为空白。

0 个答案:

没有答案