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

optionLabel and template not working as expected

6 Answers 251 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Maxim
Top achievements
Rank 1
Maxim asked on 08 Jun 2012, 04:02 PM
Using optionLabel in conjunction with template produces undesirable effect.
In this case both ${ data.State } and ${ data.Representative } come back
as undefined. You should not apply template on optionLabel.


dataTextField: "District",
dataValueField: "District",
filter: "contains",
optionLabel: "----------------",
template: kendo.template("${ data.State } ${ data.District } - ${ data.Representative }"),

6 Answers, 1 is accepted

Sort by
0
Maxim
Top achievements
Rank 1
answered on 08 Jun 2012, 04:11 PM
The only way to fix it is template like below
"#if (!data.State) { # ${ data.District } # } else { # ${ data.State } ${ data.District } - ${ data.Representative } # } #"
0
Georgi Krustev
Telerik team
answered on 13 Jun 2012, 11:07 AM
Hello Maxim,

Current "optionLabel" implementation appends a fake dataItem at the begining of the data returned by the dataSource. This fake dataItem has the dataTextField and the dataValueField properties. That is why other properties will be undefined. I believe that all items should use the defined template in order to have equal design (if any). When the optionLabel is used, then you will need to customize your template in order to handle properties, which might be undefined.

We decided to further improve this behavior in our next release of KendoUI. An "optionLabel" property which will be added to the dateItem passed to the template. Thus, if the property is true, you can easily determine what to show in the template. Let me know if this works for you.

All the best,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Maxim
Top achievements
Rank 1
answered on 14 Jun 2012, 07:45 PM
Hi Georgi,

Would not it be easier to change optionLabel to optionDataItem alowing user to assign to it an object that mimics structure of actual data object with fields containing default values?
0
Georgi Krustev
Telerik team
answered on 19 Jun 2012, 08:36 AM
Hello Maxim,

 
This seams to be a better idea than passing an optionLabel flag. Most probably we will provide the ability to set a text or an object to the optionLabel option. Thus you can define a more complex object then the one, which dropdownlist builds now. We will try to introduce this enhancement for the official release of KendoUI.

All the best,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Olivier
Top achievements
Rank 1
answered on 15 Jan 2014, 09:30 PM
Hi!

I would to know if you finally introduced the mentioned enhancement.

Thanks.
0
Georgi Krustev
Telerik team
answered on 16 Jan 2014, 08:45 AM
Hello Olivier,

This has already been implemented. I would suggest you check this help topic for more information.

Regards,
Georgi Krustev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
DropDownList
Asked by
Maxim
Top achievements
Rank 1
Answers by
Maxim
Top achievements
Rank 1
Georgi Krustev
Telerik team
Olivier
Top achievements
Rank 1
Share this question
or