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

Dropdown with ValueTemplate not functioning when used in a grid editor popup.

1 Answer 112 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 2
Michael asked on 22 Sep 2016, 11:20 AM

Version - 2016.3.914

I am experiencing a problem getting DDL with templates to render properly when used in an editor template, from a grid.

Example :

Model

public class WeightUnit
{
    public byte ID { get; set; }
    public string Code { get; set; }
    public string Description { get; set; }
}



Controller action

public ActionResult WeightUnits_Read([DataSourceRequest]DataSourceRequest request)
{
    IEnumerable<Inflight.ServiceModel.WeightUnit> results = svc.ListWeightUnits();
    return Json(results.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}



Code section in View

<div id="weights" class="panel-group" style="padding-left:5px;">
       @Html.Label("Unit", new { style = "width:80px;" })
       @(Html.Kendo().DropDownList()
               .Name("WghtUnit_ID")
               .OptionLabel(Labels.PleaseSelect)
               .DataSource(source =>
               {
                   source.Custom()
                   .ServerFiltering(false)
                   .Type("aspnetmvc-ajax")
                   .Transport(transport =>
                   {
                       transport.Read("WeightUnits_Read", "Utility");
                   })
                   .Schema(schema =>
                   {
                       schema.Data("Data")
                   .Total("Total");
                   });
                   ;
               })
               .DataTextField("Description")
                .ValueTemplate("#: data.Code # - #: data.Description #")
               .DataValueField("ID"))
   </div>

Problem

When used in an EditorTemplate for adding/editing a record to a grid, the selected value is rendered as ' - undefined'

The exact same code  works perfectly well in a basic view.

Am I doing something wrong ?  I assumed that templates could be used in any scenario.

 

Mike

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 27 Sep 2016, 09:42 AM
Hi Michael,

Please examine the following resources that describe how you can setup an editor template in the Grid component. Follow the steps in the article and you should be able to implement the behavior you are looking for.



Regards,
Viktor Tachev
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
DropDownList
Asked by
Michael
Top achievements
Rank 2
Answers by
Viktor Tachev
Telerik team
Share this question
or