在kendo UI组合框下进行选择时,如何显示特定文本?

时间:2023-01-27 20:15:10

I have a dropdownlist/combo box I made using Kendo UI for ASP .NET MVC4.

我有一个使用Kendo UI为ASP.NET MVC4制作的下拉列表/组合框。

Now for each selection/choice I pick from the combo box, I want different text to appear for each choice. E.g. Choice 1 (The text underneath the combo box should be word 1), for choice 2 (the text reads word 2), etc...

现在,对于我从组合框中选择的每个选择/选项,我希望每个选项都显示不同的文本。例如。选择1(组合框下面的文本应该是单词1),选择2(文本读取单词2)等...

I'm assuming I have to create a div for each different text I want to put underneath it but I keep getting errors. I'm not sure how to proceed. An example would be nice.

我假设我必须为我想要放在它下面的每个不同的文本创建一个div但是我一直都会遇到错误。我不知道该怎么办。一个例子会很好。

Thank you.

EDIT:

I found a javascript example that illustrates what I mean:

我发现了一个javascript示例,说明了我的意思:

E.g. How would I take this example below and turn it around for Kendo UI? http://jsfiddle.net/b6ydm/

例如。我如何在下面使用这个例子并为Kendo UI转换它? http://jsfiddle.net/b6ydm/

<script type="text/javascript">
function dropdownTip(value){
console.log(value);
    document.getElementById("result").innerHTML = value;
}</script>

<select onChange="dropdownTip(this.value)" name="search_type" style="margin-right:10px;    margin-top:2px;">
<option selected="selected" value="fruit_search">fruits</option>    
<option value="veggies_search">veggies</option>
<option value="animals_search">animals</option>
<option value="all_search">all</option>

1 个解决方案

#1


0  

E.g

<td>
  @(Html.Kendo().DropDownListFor(model => model.ViewModel.sType)
                      .HtmlAttributes(new {@class = "DropDown"})
                      .DataTextField("Text")
                      .DataValueField("Value")
                      .BindTo(Model.sList)
                      .Events(onselect => onselect.Change("ChangeEvent"))
                      )
                </td>
<span id="changingtext"></span>

function ChangeEvent(e){
   var value = this.value();
   // Use the value of the widget
   if( value == "choice1"){
        $('#changingtext').text("word1");
   }
}

I guess you could do something similiar like that.

我想你可以做类似的事情。

#1


0  

E.g

<td>
  @(Html.Kendo().DropDownListFor(model => model.ViewModel.sType)
                      .HtmlAttributes(new {@class = "DropDown"})
                      .DataTextField("Text")
                      .DataValueField("Value")
                      .BindTo(Model.sList)
                      .Events(onselect => onselect.Change("ChangeEvent"))
                      )
                </td>
<span id="changingtext"></span>

function ChangeEvent(e){
   var value = this.value();
   // Use the value of the widget
   if( value == "choice1"){
        $('#changingtext').text("word1");
   }
}

I guess you could do something similiar like that.

我想你可以做类似的事情。