与Kendo UI下拉列表选项问题相关的问题 [英] Issue with Kendo UI dropdown list optionLabel

查看:70
本文介绍了与Kendo UI下拉列表选项问题相关的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个kendoUI下拉列表,我一直遇到模板问题,我无法设法为该模板设置标题;我做了我从互联网上学到的但是效果不好,连同那个问题,我有另一个问题,对于这个下拉列表,如果我设置了optionLabel,控制台出错,下拉列表试图找到提到的字段在模板中,由于选项标签不能包含任何数据,因此无法找到它并最终报告错误。列表也没有约束。有人可以帮我从这里出去吗?我已经解决了这个下拉列表不能很好地解决我的标题的问题,但是这个optionLabel问题仍然存在,并且它很重要,不能保持原样。我不需要在开头预先选择列表的任何值。



这里是示例,我创建了一个多列下拉列表,并初始化它,将标题放到列表中,以便即使列表向上或向下滚动(另一个需要),标题仍然保持不变。如果我评论了optionLabel在这里,似乎一切都工作得很好,但如果我尝试有这个optionLabel,发生错误时,未捕获的ReferenceError:地址没有定义,在我看来,它认为optionLabel作为dataItem等尝试获取字段的值。这是我的问题,我需要它来解决。



我为它创建了一个JSFiddle示例这里

解决方案
我解决它通过在下拉与选择的标签(显示文本)和0值列表中添加另一个的DataItem,即得溶液我想到了,但我想也许我可以得到另一个,就像现在一样,它对我有用。


Hey Umais,



你试过编辑 'GridForeignKey' 编辑模板(〜/共享/ EditorTemplates /)?



你只需要设置.OptionLabel属性为下面的代码:



<预郎= 使用Javascript> @模型对象

@(
Html.Kendo()DropDownListFor(。 m => m)
.OptionLabel( 请选择...
.BindTo((SelectList)ViewData [ViewData.TemplateInfo.GetFullHtmlFieldName( )+ _ Data])





这对我有用,希望有帮助:)



干杯


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

解决方案

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.


Hey Umais,

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

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

@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


这篇关于与Kendo UI下拉列表选项问题相关的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆