Binding of dropdownlist which is in grid in a TabStrip

2 posts, 0 answers
  1. ASAP Developer
    ASAP Developer avatar
    12 posts
    Member since:
    Sep 2013

    Posted 16 Oct 2013 Link to this post

    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>
  2. Daniel
    Admin
    Daniel avatar
    2214 posts

    Posted 18 Oct 2013 Link to this post

    Hello,

    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.

    Regards,
    Daniel
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top