I am not able to bind a dropdown in a grid which is in a tabstrip. I followed the foriegn key demo but didn't work. I also tried binding dropdown to hard coded vaule but no luck. Below is the code of my view:
items.Add().Text("Charges").Content(@<text>
<h1>Hauling Charges</h1>
@(Html.Kendo().Grid<IAAI.ASAP.DomainModel.Operations.Dispatch.TowCharge>()
.Name("chargeGrid")
.Columns(columns =>
{
//columns.Bound(p => p.ChargeType).ClientTemplate("#=ChargeTypes.Charge_Description#").Title("Charge Type").Width(110); //.EditorTemplateName("testNew").Width(160);//Title("Charge Type").Width(110);//.EditorTemplateName("ChargeType");
// columns.Bound(p => p.ChargeType).EditorTemplateName("testNew").ClientTemplate("#=ChargeType.Charge_ID#");
columns.Bound(p => p.Amount).Title("Amount").Width(110);
columns.Bound(p => p.ResponsibleParty).Title("Responsible").Width(150);
//columns.ForeignKey(p => p.Charge_ID, (IEnumerable<IAAI.ASAP.DomainModel.Operations.Dispatch.ChargeType>)ViewBag.ChargeType, "Charge_ID", "Charge_Description")
// .Title("Charge Test").Width(150);
columns.ForeignKey(c => c.Charge_ID, new SelectList(new[]{
new {text="t1",value = "1"},
new {text="t2",value = "2"},
new {text="t3",value = "3"},
}, "value", "text")).Title("Charge New");
// columns.ForeignKey(p => p.Charge_ID, (System.Collections.IEnumerable)ViewBag.ChargeType, "Charge_ID", "Charge_Description").HtmlAttributes(new { id = "Charge_ID" }).Title("Charge New");
columns.Command(command => command.Destroy()).Width(110);
columns.Command(command => command.Edit()).Width(200);
})
.Editable(editable => editable.Mode(GridEditMode.PopUp))
.Pageable()
.Sortable()
.DataSource(datasource => datasource
.Ajax()
.Model(model =>
{
model.Id(p => p.Charge_ID);
// model.Field(p => p.Charge_ID).Editable(false);
//// model.Field(p => p.Charge_ID).DefaultValue(1);
model.Field(p => p.ChargeTypes).DefaultValue(
ViewBag.ChargeType as IEnumerable<IAAI.ASAP.DomainModel.Operations.Dispatch.ChargeType>);
})
.Read(read => read.Action("ChargesRead", "Dispatch", new { salvageID = "#=SalvageID#", towbill="#=TowBillNumber#", towChargeType="Hauling" }))
.Update(update => update.Action("ChargeTypes_Update", "Dispatch"))
.Destroy(destroy => destroy.Action("ChargeTypes_Destroy", "Dispatch"))
)
.ToClientTemplate()
)
</text>
items.Add().Text("Charges").Content(@<text>
<h1>Hauling Charges</h1>
@(Html.Kendo().Grid<IAAI.ASAP.DomainModel.Operations.Dispatch.TowCharge>()
.Name("chargeGrid")
.Columns(columns =>
{
//columns.Bound(p => p.ChargeType).ClientTemplate("#=ChargeTypes.Charge_Description#").Title("Charge Type").Width(110); //.EditorTemplateName("testNew").Width(160);//Title("Charge Type").Width(110);//.EditorTemplateName("ChargeType");
// columns.Bound(p => p.ChargeType).EditorTemplateName("testNew").ClientTemplate("#=ChargeType.Charge_ID#");
columns.Bound(p => p.Amount).Title("Amount").Width(110);
columns.Bound(p => p.ResponsibleParty).Title("Responsible").Width(150);
//columns.ForeignKey(p => p.Charge_ID, (IEnumerable<IAAI.ASAP.DomainModel.Operations.Dispatch.ChargeType>)ViewBag.ChargeType, "Charge_ID", "Charge_Description")
// .Title("Charge Test").Width(150);
columns.ForeignKey(c => c.Charge_ID, new SelectList(new[]{
new {text="t1",value = "1"},
new {text="t2",value = "2"},
new {text="t3",value = "3"},
}, "value", "text")).Title("Charge New");
// columns.ForeignKey(p => p.Charge_ID, (System.Collections.IEnumerable)ViewBag.ChargeType, "Charge_ID", "Charge_Description").HtmlAttributes(new { id = "Charge_ID" }).Title("Charge New");
columns.Command(command => command.Destroy()).Width(110);
columns.Command(command => command.Edit()).Width(200);
})
.Editable(editable => editable.Mode(GridEditMode.PopUp))
.Pageable()
.Sortable()
.DataSource(datasource => datasource
.Ajax()
.Model(model =>
{
model.Id(p => p.Charge_ID);
// model.Field(p => p.Charge_ID).Editable(false);
//// model.Field(p => p.Charge_ID).DefaultValue(1);
model.Field(p => p.ChargeTypes).DefaultValue(
ViewBag.ChargeType as IEnumerable<IAAI.ASAP.DomainModel.Operations.Dispatch.ChargeType>);
})
.Read(read => read.Action("ChargesRead", "Dispatch", new { salvageID = "#=SalvageID#", towbill="#=TowBillNumber#", towChargeType="Hauling" }))
.Update(update => update.Action("ChargeTypes_Update", "Dispatch"))
.Destroy(destroy => destroy.Action("ChargeTypes_Destroy", "Dispatch"))
)
.ToClientTemplate()
)
</text>