Telerik Combo Background

大兔子大兔子 提交于 2019-12-25 02:38:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!