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

Editor popups with dropdown lists inside

5 Answers 112 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 2
Michael asked on 26 Sep 2016, 01:29 PM
Hi,

I am having an issue with Dropdown list templates/value templates when used inside an editor popup called from a grid.  The code, when applied to a standard view works well.

Is this a known issue?

Regards,
Mike

5 Answers, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 28 Sep 2016, 06:44 AM
Hелло Michael,

I am afraid that the provided information is not sufficient, in order to determine what is the reason for the experienced issue. Could you share your implementation, so we could investigate the problem further?

Regards,
Nencho
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
0
Michael
Top achievements
Rank 2
answered on 08 Nov 2016, 03:01 PM

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<ServiceLayer.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

In a basic view (not in an editor pop template called from a grid) the DDL ValueTemplate line renders the selected value perfect 

e.g.

'KGS - Kilograms'

However when used inside an editor template i.e. popup editor to add a new record, the selected value is shown as :

Undefined - undefined.

 

What needs to be done differently when using ValueTemplates in a DDL configured in an editor popup ?

0
Peter Milchev
Telerik team
answered on 10 Nov 2016, 11:17 AM
Hello Michael,

I am afraid that we are unable to reproduce the issue on our side. Would you please modify the attached project so that it represents your implementation where the problem appears and send it back to us? Thus, we would be able to investigate locally and help you more efficiently. Adding a reference to the Kendo.Mvc.dll assembly should be sufficient for running the project. 

Regards,
Peter Milchev
Telerik by Progress
Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
0
Michael
Top achievements
Rank 2
answered on 10 Nov 2016, 11:38 AM

Hello Peter,

In modifying the project you kindly prepared, I have solved the problem!  Apologies, but I did not acurately describve the problem, which was that the editor template was being called from a nested grid.  To fix I simply needed to alter the ValueTemplate as follows:

.ValueTemplate("\\#: data.Code \\# - \\#: data.Description \\#")

note the backslashes.

 

Sorry, I should have realised this sooner - case closed.

 

Thanks,

Mike James

0
Peter Milchev
Telerik team
answered on 11 Nov 2016, 09:08 AM
Hello Mike,

Thank you for sharing the solution with the community.

Indeed the nested templates should be escaped according to the Kendo Templates Overview article. The deeper the nesting the more double backslashes you should use for escaping.  
  • If your template includes a literal # character, which is not part of a binding expression and is not a script code marker, then you must escape that character or it causes a template compilation error. For example, this can happen if a # is used inside a hyperlink URL or a CSS color value. Literal # in JavaScript strings are escaped via \\\\#, while literal # in external HTML script templates are escaped via \\#.
  • If your template includes a # character, which is part of a binding expression of a nested template, then this character must be escaped as well. In this way the character is ignored by the outer template, but is handled correctly by the inner template.

Regards,
Peter Milchev
Telerik by Progress
Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
Tags
DropDownList
Asked by
Michael
Top achievements
Rank 2
Answers by
Nencho
Telerik team
Michael
Top achievements
Rank 2
Peter Milchev
Telerik team
Share this question
or