Anand Thakkar
Anand Thakkar

Reputation: 302

Provide Multiple value in Kendo Dropdown DataTextField

I want to pass two value in Kendo Dropdown DataTextField.

@(Html.Kendo().DropDownList()
          .Name("language")
          .DataTextField("LanguageName")
          .DataValueField("Id")
          .Events(e => e.Change("changelanguage"))
          .BindTo(ViewBag.languages)
          .Value(ViewBag.DefaultLanguageId)
          .Template("<img src=\"" + Url.Content("~/Images/Flags/") + "${data.CountryFlagImage}\" class="SSPLanguageDropDown\" alt=\"${data.CountryFlagImage}\" />"+ "<dl><dt><dd>${ data.LanguageName }</dd></dt></dl>"))

There are two value inside the kendo dropdown first is flag & another is for language. i also want to add flag at the DataTextField with the language so how can it possible to add it at there.

Upvotes: 2

Views: 2133

Answers (1)

Bishnu Rawal
Bishnu Rawal

Reputation: 1387

You have to wire up it manually:

@section scripts{
<script type="text/javascript">
function changelanguage(e) {

                var selectedPrTemplate = kendo.template('<span class="k-icon k-i-clock"></span>&nbsp;#:data.LanguageName#'); //Instead of this image span, link your flag url

                var dataItem = this.dataItem();
                if (dataItem) {
                    this.span.html(selectedPrTemplate(dataItem));
                }
            }      
</script>

}

Upvotes: 2

Related Questions