问题
How can i Change background color of specific values in telerik Combo (MVC).
<%= Html.Telerik().ComboBox()
.Name("DropDownList")
.BindTo(new SelectList(Model, "ID", "NAME"))
.Filterable(filtering =>
{
filtering.FilterMode(AutoCompleteFilterMode.Contains);
})
.HtmlAttributes(new { })
%>
回答1:
function onDataBaound(e) {
var combobox = $(this).data('tComboBox');
var str = '<%:Html.Raw(Json.Encode(ViewData["Values"]))%>';
str = str.replace(/[\[\]']+/g, '');
str = str.split(',');
var j = 0;
if (combobox.selectedIndex == -1) {
var index = -1;
for (var i = 0; i < combobox.data.length; i++) {
if (combobox.data[i].Value == str[j]) {
index = i;
j++;
var $li = $(this).data('tComboBox').dropDown.$items.eq(index);
$li.css('color', 'red');
}
}
}
}
回答2:
You can alter the brushes associated with the control. If all you are looking to do is change the background color this should be relatively easy. Take a look at this article http://www.telerik.com/help/silverlight/radcombobox-styles-templates-modifying-brushes.html
来源:https://stackoverflow.com/questions/14986540/telerik-combo-background