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

Problems with displaying values in dropdown customized template in scheduler appointment template

2 Answers 152 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Jonas
Top achievements
Rank 1
Jonas asked on 07 Dec 2016, 08:46 AM

Hello

I'm using a kendo dropdownlistfor() inside a scheduler edit template, if I use just the basic dropdown everything works as expected, but if I try to use the templates for the dropdown all I get is undefined when I click to see the options of the dropdown. If I use the same dropdown directly on the page instead of in a template everything works ok with the dropdown template. Why are they not displaying correct in the scheduler edit template.

So the problem is not with the datasource, I get all values from the db, and the code should be fine since it works directly on the page. I guess the only thing wrong with then code is "data.name" when used inside a template since this gives the undefined. What should it be when used inside a template?

Code:

@(Html.Kendo().DropDownListFor(model => model.equipmentId)
                    .HtmlAttributes(new { style = "width: 240px", @class = "showOpsDiv" })
                    .DataTextField("name")
                    .DataValueField("id")
                    .OptionLabel("Välj Utrustning...")
                    .Value("-1")
                    .DataSource(source =>
                    {
                        source.Read(read =>
                        {
                            read.Action("GetEquipment", "Home");
                        })         
                    .ServerFiltering(true);
                    })
                   .Template("<span class=\"k-state-default\"></span><span class=\"k-state-default\"><h3>#= data.name #</h3></span>")
                   .HtmlAttributes(new { data_value_primitive = "true" })
                 )     

2 Answers, 1 is accepted

Sort by
0
Accepted
Peter Milchev
Telerik team
answered on 08 Dec 2016, 01:44 PM
Hello Jonas,

If a 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. More information could be found in the Kendo Templates Overview article.

Would you please check if escaping the hash literals in your DropDownList template solves the issue?

Regards,
Peter Milchev
Telerik by Progress
Telerik UI for ASP.NET MVC is ready for Visual Studio 2017 RC! Learn more.
0
Jonas
Top achievements
Rank 1
answered on 08 Dec 2016, 02:54 PM

Hello Peter

That did the trick! :-)

Thank you!

/Jonas

Tags
Scheduler
Asked by
Jonas
Top achievements
Rank 1
Answers by
Peter Milchev
Telerik team
Jonas
Top achievements
Rank 1
Share this question
or