Reputation: 302
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
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> #: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