Editor popups with dropdown lists inside

6 posts, 0 answers
  1. Michael
    Michael avatar
    11 posts
    Member since:
    Sep 2015

    Posted 26 Sep Link to this post

    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
  2. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 28 Sep Link to this post

    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
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Michael
    Michael avatar
    11 posts
    Member since:
    Sep 2015

    Posted 08 Nov Link to this post

    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 ?

  5. Peter Milchev
    Admin
    Peter Milchev avatar
    144 posts

    Posted 10 Nov Link to this post

    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.
  6. Michael
    Michael avatar
    11 posts
    Member since:
    Sep 2015

    Posted 10 Nov in reply to Peter Milchev Link to this post

    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

  7. Peter Milchev
    Admin
    Peter Milchev avatar
    144 posts

    Posted 11 Nov Link to this post

    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.
Back to Top
UI for ASP.NET MVC is VS 2017 Ready