最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Pass a custom CSS class to the Kendo's Dropdown Widget - Stack Overflow

programmeradmin3浏览0评论

I want to pass a custom CSS class to the dropdown HTML container that gets generated when calling .kendoDropDownList() method on a <select> or <input> element.

As you'll see in this fiddle ( / ) the HTML I'm interested in is this:

<div class="k-list-container k-popup k-group k-reset" data-role="popup">
    <ul unselectable="on" class="k-list k-reset" tabindex="-1" role="listbox" aria-hidden="true" aria-live="off" style="overflow: auto;">
        <li tabindex="-1" role="option" unselectable="on" class="k-item k-state-selected k-state-focused">option 1</li>
        <li tabindex="-1" role="option" unselectable="on" class="k-item">option 2</li>
        <li tabindex="-1" role="option" unselectable="on" class="k-item">option 3</li>
        <li tabindex="-1" role="option" unselectable="on" class="k-item">option 4</li>
        <li tabindex="-1" role="option" unselectable="on" class="k-item">option 5</li>
    </ul>
</div>

I've checked the documentation but I did not find any answer regarding this specific issue. What I'm more interested in is to find a clean, "kendo'ish" way of solving this.

I want to pass a custom CSS class to the dropdown HTML container that gets generated when calling .kendoDropDownList() method on a <select> or <input> element.

As you'll see in this fiddle ( http://jsfiddle/lav911/n9V4N/ ) the HTML I'm interested in is this:

<div class="k-list-container k-popup k-group k-reset" data-role="popup">
    <ul unselectable="on" class="k-list k-reset" tabindex="-1" role="listbox" aria-hidden="true" aria-live="off" style="overflow: auto;">
        <li tabindex="-1" role="option" unselectable="on" class="k-item k-state-selected k-state-focused">option 1</li>
        <li tabindex="-1" role="option" unselectable="on" class="k-item">option 2</li>
        <li tabindex="-1" role="option" unselectable="on" class="k-item">option 3</li>
        <li tabindex="-1" role="option" unselectable="on" class="k-item">option 4</li>
        <li tabindex="-1" role="option" unselectable="on" class="k-item">option 5</li>
    </ul>
</div>

I've checked the documentation but I did not find any answer regarding this specific issue. What I'm more interested in is to find a clean, "kendo'ish" way of solving this.

Share Improve this question asked May 2, 2014 at 11:23 ZubzobZubzob 2,7534 gold badges30 silver badges46 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

This is how I used to solve this task:

$('select').kendoDropDownList({
    open: function(e) {
        e.sender.popup.element.addClass('test');
    }
});

I was not able to find any configuration way.

Demo: http://jsfiddle/n9V4N/2/

Or another way to do it:

var dropDown = $('select').kendoDropDownList().data("kendoDropDownList");
dropDown.list.addClass('test');

Demo: http://jsfiddle/n9V4N/3/

发布评论

评论列表(0)

  1. 暂无评论