1
我有一个基于MVC的子网格kendo网格,数据可以使用弹出模式进行编辑。这一切工作正常, ,但是当我添加一个子行我想有相关的字段到父表已经填充。 我的代码如下所示:Telerik kendo MVC子网格与编辑组合
<script id="subGrid" type="text/kendo-tmpl">
@(Html.Kendo().Grid<SiennInvoice.Models.InvoiceModel>()
.Name("grid_#=ID#") // template expression, to be evaluated in the master context
.Columns(columns =>
{
columns.Bound(c => c.Description);
columns.ForeignKey(c => c.IntervalType, (System.Collections.IEnumerable)ViewBag.IntervalTypesDdl, "Value", "Text");
columns.Bound(c => c.Interval);
columns.Bound(c => c.Amount);
columns.Bound(c => c.InvoiceDate);
columns.ForeignKey(c => c.Currency, (System.Collections.IEnumerable)ViewBag.CurrenciesDdl, "Value", "Text");
columns.Bound(c => c.Done);
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(180);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.PopUp))
.Pageable()
.Sortable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(10)
.Read(read => read.Action("HierarchyBinding_Invoices", "OrderEdit", new { OrderId = "#=ID#" }))
.Events(events => events.Error("error_handler"))
//.Model(model => model.Id(o => o.ID))
.Model(model =>
{
model.Id(o => o.ID);
model.Field(field => field.OrderId).DefaultValue("#=ID#");
})
//.Create(create => create.Action("Invoice_Create", "OrderEdit"))
//.Update(update => update.Action("Invoice_Update", "OrderEdit"))
//.Destroy(destroy => destroy.Action("Invoice_Destroy", "OrderEdit"))
//.Read(read => read.Action("Invoices_Read", "ToBeInvoiced"))
.Create(create => create.Action("Invoices_Create", "ToBeInvoiced"))
.Update(update => update.Action("Invoices_Update", "ToBeInvoiced"))
.Destroy(destroy => destroy.Action("Invoices_Destroy", "ToBeInvoiced"))
)
.ToClientTemplate()
)
</script>
的问题是在默认值,我不能像我在读动作确实使用“#= ID”在这里, 这引起了一个错误。 但是,我可以使用1,2或3,但我希望这种动态每行。
有人可以帮助我吗? 谢谢。