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

javascript - How to remove item of kendo dropDownList if it is the last one? - Stack Overflow

programmeradmin0浏览0评论

I can remove all items except the last one from the kendo dropdownlist. After the last one is removed, the previous items reappear.

Here is a jsFiddle: /

var dropDown = $("select").data("kendoDropDownList");
var itemToRemove = dropDown.dataSource.at(0);
dropDown.dataSource.remove(itemToRemove);
dropDown.select(0);

Any ideas how to solve this?

I can remove all items except the last one from the kendo dropdownlist. After the last one is removed, the previous items reappear.

Here is a jsFiddle: http://jsfiddle/lpoellabauer/Jw4Cz/

var dropDown = $("select").data("kendoDropDownList");
var itemToRemove = dropDown.dataSource.at(0);
dropDown.dataSource.remove(itemToRemove);
dropDown.select(0);

Any ideas how to solve this?

Share Improve this question asked Apr 30, 2012 at 11:17 l.poellabauerl.poellabauer 7563 gold badges11 silver badges18 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

HTML:

<select>
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
<option id="none" value="none"></option>
</select>

<a href="#">remove first</a>

JS:

$("select").kendoDropDownList();

$("a").click(function(){
    var dropDown = $("select").data("kendoDropDownList");
    var itemToRemove = dropDown.dataSource.at(0);
    dropDown.dataSource.remove(itemToRemove);
    dropDown.select(0);
});
$('none').css({display:none});

发布评论

评论列表(0)

  1. 暂无评论