我正在使用Kendo UI DropDownList元素带过滤器搜索。Kendo UI [DropDownList] - 多个元素的冲突
如果内部下拉用户搜索和搜索项不可用我显示+ Add
链接...
这正按预期只有当我有一个<select>
箱
感谢@Jonathan
,谁在帮助上述:)
但是,得到的问题,如果我有1个多选择框
jQuery的
$(document).ready(function() {
// set up the delay function
var delay = (function(){
var timer = 0;
return function(callback, ms) {
clearTimeout (timer);
timer = setTimeout(callback, ms);
};
})();
$(".selectBox").kendoDropDownList({
filter: "contains"
});
// set up the event handler
$(".k-list-filter input").keyup(function() {
// wait for Kendo to catch up
delay(function() {
// check the number of items in the list and make sure we don't already have an add link
if ($('.k-list-scroller ul > li').length === 0 && !($(".newItem").length)) {
$('.k-list-filter .k-i-search').hide();
$('.k-list-filter').append('<a href="javascript:;" class="newItem">+ Add</a>');
}
// check the number of items in the list
if ($('.k-list-scroller ul > li').length > 0) {
$('.k-list-filter .k-i-search').show();
$('.k-list-filter .newItem').remove();
}
}, 500); // 500 ms delay before running code
});
});
HTML
<div class="row">
<div class="col-xs-4">
<div class="field">
<select class="selectBox">
<option>-- Select 1 --</option>
<option>Lorem</option>
<option>Ipsum</option>
<option>Dolar</option>
</select>
</div>
</div>
<div class="col-xs-4">
<div class="field">
<select class="selectBox">
<option>-- Select 2 --</option>
<option>Lorem</option>
<option>Ipsum</option>
<option>Dolar</option>
<option>Sit amet lieu</option>
</select>
</div>
</div>
<div class="col-xs-4">
<div class="field">
<select class="selectBox">
<option>-- Select 3 --</option>
<option>Lorem</option>
<option>Ipsum</option>
<option>Dolar</option>
</select>
</div>
</div>
</div>
你好** @肖恩·米奇**感谢您的澄清......但它不是在某些情况下在这里工作..唯一的问题是,它正在为第一选择的选项。 ..直到我清除所有搜索字段的数据,它不工作...如果我点击外部/关闭下拉菜单,所有搜索字段值应该被清除,然后工作完成:) – Reddy