Saturday, 15 August 2015

asp.net mvc - Unable to bind drop down list in telerik kendo mvc grid -



asp.net mvc - Unable to bind drop down list in telerik kendo mvc grid -

i'm having difficulty binding dropdown list in telerik mvc kendo grid.

i have collection of records bound grid , each record has foregin key property. rendering text box in place dropdown should be.

i have searched throrugh telerik documentation , demo code have working dropdown shows them using clienttemplate on field , doesn't show code template.

in controller action populate viewdata collection follows:

ienumerable<detailslotdto> slots = mapper.todto(detailslotrepository.getall()); viewdata["slots"] = slots;

and detailslotdto class follows:

public class detailslotdto { public int id { get; set; } public string description { get; set; } }

i trying setup grid in view follows:

@(html.kendo().grid<sft.web.dtos.syndicatedrecorddto>() .name("slotgrid") .columns(c => { c.bound(f => f.detailslot).clienttemplate(html.kendo().dropdownlist() .bindto(viewdata["slots"] ienumerable<sft.web.dtos.detailslotdto>) .name("slotdesc_#=id#") .datatextfield("description") .datavaluefield("id") .toclienttemplate().tohtmlstring() ); c.bound(f => f.client); c.bound(f => f.product); c.bound(f => f.start); c.bound(f => f.end); c.bound(f => f.purchaseorder); c.bound(f => f.value); c.bound(f => f.kpipenalty); c.bound(f => f.notes); }) .toolbar(t => { t.create(); }) .editable(e => e.mode(grideditmode.incell)) .datasource(d => d .ajax() .batch(false) .serveroperation(false) .model(m => { m.id(r => r.id); m.field(r => r.detailslot); m.field(r => r.client).editable(true); m.field(r => r.product).editable(true); m.field(r => r.start).editable(true); m.field(r => r.end).editable(true); m.field(r => r.purchaseorder).editable(true); m.field(r => r.value).editable(true); m.field(r => r.kpipenalty).editable(true); m.field(r => r.notes).editable(true); }) .read(read => read.action("slotgrid_read", "salesfee", new { id = @model.salesfeeid })) .create(create => create.action("slotgrid_create", "salesfee")) .update(update => update.action("slotgrid_update", "salesfee")) .destroy(destroy => destroy.action("slotgrid_destroy", "salesfee")) ) )

any help on appreciated. spent day yesterday playing around trying work , haven't had much luck.

thank in advance

if want show dropdown in edit mode have utilize "foreignkey" column in kendo grid.

columns.foreignkey(p => p.detailslot, (system.collections.ienumerable)viewdata["slots"], "id", "description");

please check link, in link have posted total code , demo project.

asp.net-mvc telerik telerik-grid

No comments:

Post a Comment