Hi,
I have a Master Detail Grid in Kendo UI
I want to add rows to Detail Grid with a Foriegn Key Column that is driven by Master Id, how do i accomplish this ?
I have highlighted the Foreign Key Column in bold
@(Html.Kendo().Grid<PackageModel>()
.Name("RGrid")
.Columns(col =>
{
col.Bound(c => c.Name).Visible(true);
col.Bound(c => c.PackageName).Visible(true).Title("Package");
})
.DataSource(ds => ds
.Ajax()
.Events(e => e.RequestStart("onDataRequestStart"))
.Model(m =>
{
m.Id(c => c.OId);
})
.Read(read => read.Action("ReadPackages", "RGrid", new { area = "Recommendation", gridSettings = "##settings##" }))
)
.ClientDetailTemplateId("recostemplate")
.Navigatable()
.Pageable(p => p.PageSizes(true))
.Filterable()
.Sortable()
.Selectable(selectable => selectable.Mode(GridSelectionMode.Single))
)
<script id="recostemplate" type="text/kendo-tmpl">
@(Html.Kendo().Grid<SE.OrderBook.Web.Models.View.RecommendationModel>()
.Name("RecosGrid#=Id#")
.Columns(columns =>
{
columns.Bound(o => o.Id).Title("Id").Visible(true);
columns.ForeignKey(o => o.DeliverableId, commonService.GetDeliverableDropList(), "Id", "Value");
columns.Bound(o => o.DeliverableName).Title("Deliverable").Visible(true);
columns.Bound(o => o.Included).Visible(true);
columns.Bound(o => o.ServiceStart).Format("{0:d}").Title("Service<br />Start");
columns.Bound(o => o.ServiceEnd).Format("{0:d}").Title("Service<br />End");
columns.Bound(o => o.Year1).Visible(true);
columns.Bound(o => o.Total).Visible(true);
columns.Bound(o => o.PackageId).Hidden(true);
columns.Command(cmd => { cmd.Edit().UpdateText("Save"); /*cmd.Destroy();*/ }).Visible(true).Width("10%");
})
.DataSource(ds => ds
.Ajax()
.PageSize(5)
.Model(m =>
{
m.Id(c => c.Id);
m.Field(c => c.PackageId).DefaultValue("#=Id#");
})
.Read(read => read.Action("Read", "Home", new { area = "Recommendation", id = "#=Id#" }))
.Create(update => update.Action("Create", "Recos", new { area = "Recommendation" }))
.Update(update => update.Action("Update", "Recos", new { area = "Recommendation" }))
.Destroy(delete => delete.Action("Delete", "Recos", new { area = "Recommendation" }))
)
.ToolBar(toolbar => { toolbar.Create(); })
.Events(events =>
{
events.Edit("onRecoDetailsEdit");
events.Save("onRecoDetailsSave");
})
.Editable(e => e.Mode(GridEditMode.PopUp))
.Pageable()
.Sortable()
.ToClientTemplate())
</script>
I need to pass package Id into commonService.GetDeliverableDropList() but i am not sure how to accomplish this?
I think solution to this is only possible at run time through AJAX, if particular than is there an example how i can populate foriegn key colum dropdown list through AJAX ?
Waiting for Response,
Kind Regards,
I have a Master Detail Grid in Kendo UI
I want to add rows to Detail Grid with a Foriegn Key Column that is driven by Master Id, how do i accomplish this ?
I have highlighted the Foreign Key Column in bold
@(Html.Kendo().Grid<PackageModel>()
.Name("RGrid")
.Columns(col =>
{
col.Bound(c => c.Name).Visible(true);
col.Bound(c => c.PackageName).Visible(true).Title("Package");
})
.DataSource(ds => ds
.Ajax()
.Events(e => e.RequestStart("onDataRequestStart"))
.Model(m =>
{
m.Id(c => c.OId);
})
.Read(read => read.Action("ReadPackages", "RGrid", new { area = "Recommendation", gridSettings = "##settings##" }))
)
.ClientDetailTemplateId("recostemplate")
.Navigatable()
.Pageable(p => p.PageSizes(true))
.Filterable()
.Sortable()
.Selectable(selectable => selectable.Mode(GridSelectionMode.Single))
)
<script id="recostemplate" type="text/kendo-tmpl">
@(Html.Kendo().Grid<SE.OrderBook.Web.Models.View.RecommendationModel>()
.Name("RecosGrid#=Id#")
.Columns(columns =>
{
columns.Bound(o => o.Id).Title("Id").Visible(true);
columns.ForeignKey(o => o.DeliverableId, commonService.GetDeliverableDropList(), "Id", "Value");
columns.Bound(o => o.DeliverableName).Title("Deliverable").Visible(true);
columns.Bound(o => o.Included).Visible(true);
columns.Bound(o => o.ServiceStart).Format("{0:d}").Title("Service<br />Start");
columns.Bound(o => o.ServiceEnd).Format("{0:d}").Title("Service<br />End");
columns.Bound(o => o.Year1).Visible(true);
columns.Bound(o => o.Total).Visible(true);
columns.Bound(o => o.PackageId).Hidden(true);
columns.Command(cmd => { cmd.Edit().UpdateText("Save"); /*cmd.Destroy();*/ }).Visible(true).Width("10%");
})
.DataSource(ds => ds
.Ajax()
.PageSize(5)
.Model(m =>
{
m.Id(c => c.Id);
m.Field(c => c.PackageId).DefaultValue("#=Id#");
})
.Read(read => read.Action("Read", "Home", new { area = "Recommendation", id = "#=Id#" }))
.Create(update => update.Action("Create", "Recos", new { area = "Recommendation" }))
.Update(update => update.Action("Update", "Recos", new { area = "Recommendation" }))
.Destroy(delete => delete.Action("Delete", "Recos", new { area = "Recommendation" }))
)
.ToolBar(toolbar => { toolbar.Create(); })
.Events(events =>
{
events.Edit("onRecoDetailsEdit");
events.Save("onRecoDetailsSave");
})
.Editable(e => e.Mode(GridEditMode.PopUp))
.Pageable()
.Sortable()
.ToClientTemplate())
</script>
I need to pass package Id into commonService.GetDeliverableDropList() but i am not sure how to accomplish this?
I think solution to this is only possible at run time through AJAX, if particular than is there an example how i can populate foriegn key colum dropdown list through AJAX ?
Waiting for Response,
Kind Regards,