Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a kendoUI dropdown list, I've been having issues with the template and I couldn't manage to have a header for that template; I did what I learned from internet but it didn't work well, along with that issue, I had another issue, for this dropdown list, if I set optionLabel, there's an error in console, the dropdown list tries to find the fields mentioned in the template and since option label cannot have any data, it doesn't find it and ends up reporting an error. the list is not bound as well. Can anyone help me out here? I've already resolved the issue for this dropdown not working well the my header, but this optionLabel issue is still there, and it's important, can't be left as it is. I don't need any value of the list to be pre-selected at the beginning.

here's the sample, I create a multi-column dropdown list, and initialize it, put a header to the list so that the header stays still even if the list is scrolled up or down (another one of my needs). if I comment the "optionLabel" here, everything seems to be working just fine, but if I try to have this optionLabel, error occurs, "Uncaught ReferenceError: Address is not defined", as I see it, it considers the optionLabel as a dataItem and so tries to get the value of the fields. That's my issue, I need it to be resolved.

I created a JSFiddle example for that here
Posted

I solved it by adding another dataItem in the drop down list with select label (display text) and 0 value, that was the solution I had in mind but I was thinking maybe I could get another one, as for now, it's working for me.
 
Share this answer
 
Hey Umais,

Have you tried editing the 'GridForeignKey' Editor Template (~/Shared/EditorTemplates/) ?

You just have to set .OptionLabel property as following code:

JavaScript
@model object
           
@(
 Html.Kendo().DropDownListFor(m => m)
 .OptionLabel("Please Select ...") 
 .BindTo((SelectList)ViewData[ViewData.TemplateInfo.GetFullHtmlFieldName("") + "_Data"])
)


That worked for me, hope that helps :)

Cheers
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900