This question is locked. New answers and comments are not allowed.
Hi all,
MVC:3
Telerik: 2011.1.315
I have a Master/Detail scenario for User/Address with two grids.
The issue I'm having is when inserting a detail Address in Popup mode; the [User] ID is returned to the controller with a 0 value. By changing the edit mode to InLine, the User Id returns the correct value. Why is it not the same in Popup mode?
Here's a short version of the view:
Html.Telerik().Grid<User>() .Name("Persons") .DataKeys(keys => { keys.Add(o => o.Id); }) .DataBinding(dataBinding => { dataBinding.Ajax() .Select("_Index", "Users") .Insert("Create", "Users") .Update("Edit", "Users") .Delete("Delete", "Users"); }) .ToolBar(commands => { commands.Insert().ButtonType(type).ImageHtmlAttributes(new { style = "margin-left:0" }); }) .Columns(columns => { columns.Bound(o => o.LastName); columns.Bound(o => o.FirstName); columns.Bound(o => o.Phone); columns.Bound(o => o.Email); columns.Bound(o => o.Role); columns.Bound(o => o.Status); columns.Bound(o => o.Client).Hidden(true).Title("").ReadOnly(true); columns.Bound(o => o.Fax).Hidden(true).Title(""); columns.Bound(o => o.Gender).Hidden(true).Title(""); columns.Bound(o => o.Language).Hidden(true).Title(""); columns.Bound(o => o.Password).Hidden(true).Title(""); columns.Bound(o => o.Title).Hidden(true).Title(""); columns.Bound(o => o.Username).Hidden(true).Title(""); columns.Command(commands => { commands.Edit().ButtonType(type); commands.Delete().ButtonType(type); }).Width(80).Title(""); }) .DetailView(detailView => detailView.ClientTemplate( Html.Telerik().TabStrip() .Name("TabStrip_<#= Id #>") .SelectedIndex(0) .Items(items => { items.Add().Text("Addresses").Content( Html.Telerik().Grid<Address>() .Name("Addresses_" + "<#= Id #>") .Editable(editing => editing.Enabled(true).Mode(GridEditMode.InLine)) .DataKeys(keys => { keys.Add(o => o.AddressId); }) .DataBinding(dataBinding => { dataBinding.Ajax() .Select("GetAdderssList", "Users", new { id = "<#= Id #>" }) .Insert("AddAddress", "Users", new { id = "<#= Id #>" }) // This is always 0 in Popup mode. Why?! .Update("EditAddress", "Users") .Delete("DeleteAddress", "Users"); }) .ToolBar(commands => { commands.Insert().ButtonType(type).ImageHtmlAttributes(new { style = "margin-left:0" }); }) .Columns(columns => { columns.Bound(o => o.AddressId).Width(101).Visible(false); columns.Bound(o => o.AddressType); columns.Bound(o => o.AddressLine1).Width(140); columns.Bound(o => o.AddressLine2).Width(200); columns.Bound(o => o.AddressLine3).Width(200); columns.Bound(o => o.City); columns.Bound(o => o.Country); columns.Bound(o => o.Status); columns.Command(commands => { commands.Edit().ButtonType(type); commands.Delete().ButtonType(type); }).Width(80).Title(""); }) .ToHtmlString() ); }).ToHtmlString() )) The controller:
[GridAction] public ActionResult AddAddress(Address model, int id) { // InLine mode: id = the person's ID. // Popup mode: id = 0. Why ? .... }Thanks in advance for any insight,