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,但我希望這種動態每行。
有人可以幫助我嗎? 謝謝。