This is a migrated thread and some comments may be shown as answers.

Binding of dropdownlist which is in grid in a TabStrip

1 Answer 30 Views
This is a migrated thread and some comments may be shown as answers.
ASAP Developer
Top achievements
Rank 1
ASAP Developer asked on 16 Oct 2013, 03:08 PM
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:

<h1>Hauling Charges</h1>
.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))
.DataSource(datasource => datasource
.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"))


1 Answer, 1 is accepted

Sort by
Telerik team
answered on 18 Oct 2013, 04:57 PM

Could you clarify what exactly is not working? The text is not matched to the value when displaying the cells, the value is not correctly updated or the dropdownlist is not shown. Note that you should use the UIHintAttribute to specify that the "GridForeignKey" editor template should be used when using PopUp editing because the EditorForModel helper is used.

Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Asked by
ASAP Developer
Top achievements
Rank 1
Answers by
Telerik team
Share this question