I have spent the night searching, and can't seem to find an answer for what must be a fairly common question.
I have a grid of 'Clients'. The client grids detail template is a grid of Licenses. Everything works fine, except when I add a row to the license grid, I can't get access to the Client's Id column.
ViewModel
My View:
My Controller method for creating a new license:
I have even tried hard coding an Id, and it still doesn't work:
and in my controller method, 'clientId' is still 0.
How can I pass the client (parent) id to the CreateLicenseForClient method? Without that id, I can't establish the Client has-many Licenses relationship.
Thanks,
~S
I have a grid of 'Clients'. The client grids detail template is a grid of Licenses. Everything works fine, except when I add a row to the license grid, I can't get access to the Client's Id column.
ViewModel
public class LicenseClient{ public int Id { get; set; } public String Name { get; set; } public String Email { get; set; } public String City { get; set; } public int NumLicenses { get; set; }}public class LicenseInfo{ public int ClientId { get; set; } public Guid LicenseId { get; set; } public String Product { get; set; } public int Count { get; set; } public String Notes { get; set; }}@{ ViewBag.Title = "Index";}<h2>Client Licenses</h2>@( Html.Kendo().Grid<CoreLM.Models.ViewModels.LicenseClient>() .Name("clientGrid") .Columns( columns => { columns.Bound(c => c.Name); columns.Bound(c => c.City); columns.Bound(c => c.Email); columns.Bound(c => c.NumLicenses).Title("Total Licenses"); }) .DataSource(ds => ds.Ajax() .Read(r => r.Action("GetLicenseClients", "License")) ) .Sortable() .Scrollable() .HtmlAttributes(new { style = "height:500px;" }) .ClientDetailTemplateId("ClientLicenseDetailTemplate"))<script id="ClientLicenseDetailTemplate" type="text/kendo-tmpl" >@( Html.Kendo().Grid<CoreLM.Models.ViewModels.LicenseInfo>() .Name("clientLicensesGrid_#=Id#") .Columns(columns => { columns.Bound(c => c.Product); columns.Bound(c => c.Count).Title("Licenses"); columns.Bound(c => c.Notes); columns.Command(c => c.Destroy()); columns.Command(c => c.Edit()); }) .DataSource(ds => ds.Ajax() .Read(r => r.Action("GetLicensesForClient", "License", new { clientId = "#=Id#" })) .Create(c => c.Action("CreateLicenseForClient", "License", new { clientId = "#=Id#})) .Update(u => u.Action("ChangeLicensesForClient", "License")) .Destroy(d => d.Action("DeleteLicensesForClient", "License")) .Model(m => { m.Id(l => l.LicenseId); }) ) .ToolBar(tb => tb.Create()) .Scrollable() .Sortable() .Editable() .ToClientTemplate())</script>[AcceptVerbs(HttpVerbs.Post)]public ActionResult CreateLicenseForClient([DataSourceRequest]DataSourceRequest request, int clientId, LicenseInfo li){ //clientId is always 0}I have even tried hard coding an Id, and it still doesn't work:
.Create(c => c.Action("CreateLicenseForClient", "License", new { clientId = 99}))and in my controller method, 'clientId' is still 0.
How can I pass the client (parent) id to the CreateLicenseForClient method? Without that id, I can't establish the Client has-many Licenses relationship.
Thanks,
~S