我正在使用详细模板制作剑道网格:
当您编辑 SC 分配网格时,它将显示一个下拉列表ServiceGroup
,当您从下拉列表中选择并将鼠标移离网格时,ServiceGroup
它将变为空。
这是我的主要网格代码:
@(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())
</script>
这是我的下拉编辑器模板:
@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)
)
我唯一担心的是,在我从下拉列表中选择服务组后,服务组变为空白。