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

Special Characters in an inline dropdown

2 Answers 1092 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Cody
Top achievements
Rank 1
Cody asked on 31 Aug 2018, 07:11 PM

I'm trying to add a bullet point to my dropdown entries and while it works when it displays in the dropdown, when I try to edit it it reverts back to the character code.

Here is the code I'm using for my dropdown and it's in a grid with inline editing.

 $('<input required name="' + options.field + '"/>')
        .appendTo(container)
        .kendoDropDownList({
            dataTextField: "Details",
            dataValueField: "Id",
            dataSource: dataSource,
            optionsLabel: {
                Details: "Choose an item...",
                Id: -1
            },
            template: "#= data.Details #"
        });

Any help would be appreciated.

 

2 Answers, 1 is accepted

Sort by
0
Cody
Top achievements
Rank 1
answered on 31 Aug 2018, 09:25 PM

Looking at the problem a bit more here is a better question to ask.

How do I encode the selected value of a dropdown list?

The template works just fine but once an item is selected the encoding is gone.

0
Dimitar
Telerik team
answered on 04 Sep 2018, 11:59 AM
Hello Cody,

In general, the special Kendo UI Templates syntax(#) allows to specify how the output is displayed:

    1. Render values as HTML: #= #.
      1. Use HTML encoding to display values: #: #.
Taking the above into consideration, to resolve the currently described scenario, just use the required syntax in the DropDownList's value template:
$("#color").kendoDropDownList({
  ...                      
  valueTemplate: "#= data.text #",
});

The above is also demonstrated on the following DropDownList example.

In case you have any additional questions, please let me know.

Regards,
Dimitar
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
DropDownList
Asked by
Cody
Top achievements
Rank 1
Answers by
Cody
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or