I'm not sure if this is a bug, or something I'm doing wrong - I can't pass the primary key of the parent record to the insert controller of the details grid.
The grid is :-
The create controller is:-
The problem is that the variable PackageID is always 0, even though fiddler shows the correct value being passed:-
e.g:-
I've tried builds 2012.3.1114 and 2012.3.1210, but neither work. Am I doing something wrong? (unfortunately I can't find any examples for editing of a hierarchical grid - so it's hard to be sure).
The grid is :-
@(Html.Kendo().Grid<
CMS_2013.Models.CMS_SSIS_Package
>()
.Name("Grid")
.Events(e=>e.Edit("onEdit"))
.Columns(columns=>
{columns.Bound(p=>p.PackageID).Title("ID");
columns.Bound(p => p.UniqueName).Title("Name");
columns.Bound(p => p.PackageName).Title("Value");
columns.Bound(p => p.PackageDescription).Title("Description");
columns.Command(command => { command.Edit(); command.Destroy(); });
})
.ClientDetailTemplateId("configTemplate")
.ToolBar(commands=>commands.Create())
.Editable(editable=>editable
.Mode(GridEditMode.PopUp))
.DataSource(dataSource=>dataSource
.Ajax()
.Model(m=>m.Id(p=>p.PackageID))
.Events(events => events.Error("error"))
.PageSize(10)
.Read(read=>read.Action("ReadPackages","Settings"))
.Create(create=>create.Action("InsertPackage","Settings"))
.Update(update=>update.Action("UpdatePackage","Settings"))
.Destroy(delete=>delete.Action("DeletePackage","Settings"))
)
.Pageable()
.Sortable()
.Filterable()
)
</
div
>
<
script
id
=
"configTemplate"
type
=
"text/kendo-tmpl"
>
@(Html.Kendo().Grid<
CMS_2013.Models.CMS_SSIS_Package_Config
>()
.Name("Configs_#=PackageID#")
.Events(e=>e.Edit("onEdit2"))
.Columns(columns =>
{
columns.Bound(o => o.ConfigName);
columns.Bound(o => o.ConfigFile);
columns.Command(command => { command.Edit(); command.Destroy(); });
})
.ToolBar(commands=>commands.Create())
.Editable(editable=>editable
.Mode(GridEditMode.PopUp))
.DataSource(dataSource => dataSource
.Ajax()
.Model(m=>m.Id(p=>p.ConfigID))
.Read(read => read.Action("ReadConfigs", "Settings", new { PackageID = "#=PackageID#" }))
.Create(create=>create.Action("InsertConfig","Settings", new { PackageID = "#=PackageID#" }))
.Update(update=>update.Action("UpdateConfig","Settings"))
.Destroy(delete=>delete.Action("DeleteConfig","Settings"))
)
.Pageable()
.Sortable()
.ToClientTemplate()
)
</
script
>
[AcceptVerbs(HttpVerbs.Post)]
public
ActionResult InsertConfig([DataSourceRequest] DataSourceRequest request, Models.CMS_SSIS_Package_Config config,
int
PackageID)
{
config.PackageID = PackageID;
_repository.InsertConfig(config);
return
Json(
new
[] { config }.ToDataSourceResult(request, ModelState));
}
e.g:-
http://localhost:51898/Settings/InsertConfig?PackageID=2