I have a grid for a list of locations, each row expands to show the services at that location. When I click to create a new locationService, I need to pass the locations ID to the controller. The location is the parent grid and location services are the child. I can't figure out how to do this.
@* LOCATIONS GRID *@
<div class="row">
<div class="col-md-12">
@(Html.Kendo().Grid<BiddingSite.Data.Dtos.LocationDto>
()
.Name("locationsGrid")
.AutoBind(false)
.Columns(columns =>
{
columns.Bound(c => c.Id).Title("Id").Hidden();
columns.Bound(c => c.Address).Title("Address").Width(25);
columns.Bound(c => c.City).Title("City").Width(15);
columns.Bound(c => c.StateName).Title("State").Width(10);
columns.Bound(c => c.Zip).Title("Zip").Width(10);
columns.Bound(c => c.Number).Title("SiteNumber").Width(10);
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(75);
})
.ToolBar(toolBar =>
{
toolBar.Create();
})
.DataSource(datasource => datasource.Ajax()
.Read(read => read.Action("locations_Read", "OpenBids").Data("getAdditionalParams_Locations_Read"))
.Model(model => model.Id(p => p.Id))
.Create(create => create.Action("Location_Create", "OpenBids").Data("getAdditionalParams_Location_Create"))
.Update(update => update.Action("Location_Update", "OpenBids"))
.Destroy(update => update.Action("Location_Delete", "OpenBids"))
)
.Events(events => events.DetailInit("locationGridEvent_ExpandRow"))
.Sortable()
.Filterable()
.Editable(editable => editable.Mode(GridEditMode.InLine))
.ClientDetailTemplateId("template")
)
</div>
</div>
</div>
@* LOCATION SERVICES GRID *@
<script id="template" type="text/kendo-tmpl">
@(Html.Kendo().Grid<BiddingSite.Models.ProposalUpdateLocationServiceModel>
()
.Name("locationServicesGrid_#=Id#")
.Columns(columns =>
{
columns.Bound(c => c.TrackingNumber).Title("TrackingNumber").Width(15);
columns.Bound(c => c.Service).Title("Service").Width(100).Locked();
columns.Bound(c => c.ServiceClass).Title("ServiceClass").Width(15);
columns.Bound(c => c.ServiceType).Title("ServiceType").Width(15);
columns.Bound(c => c.EquipmentType).Title("EquipmentType").Width(15);
columns.Bound(c => c.MaterialType).Title("MaterialType").Width(15);
columns.Bound(c => c.Quantity).Title("Quantity").Width(10);
columns.Bound(c => c.ContainerSize).Title("ContainerSize").Width(10);
columns.Bound(c => c.Frequency).Title("Frequency").Width(10);
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);
})
.ToolBar(toolBar =>
{
toolBar.Create();
})
.DataSource(datasource => datasource.Ajax()
.Read("locationServices_Read", "OpenBids", new { id = "#=Id#" })
.Model(model => model.Id(p => p.Id))
.Model(model => model.Field(p => p.Service).Editable(false))
.Create(create => create.Action("LocationService_Create", "OpenBids").Data("getAdditionalParams_LocationService_Create")) // this is where I need to pass the ID of the parent row to have the correct location
.Update(update => update.Action("LocationService_Update", "OpenBids"))
.Destroy(update => update.Action("LocationService_Delete", "OpenBids"))
)
.Editable(editable => editable.Mode(GridEditMode.PopUp))
.Events(e => e.Edit("onEdit"))
.ToClientTemplate()
)
</script>