[Java教程]EasyUI combobox
0
2016-12-23 11:00:05
高度自适应
data-options="required:true,editable:false,panelHeight:'auto',panelMaxHeight:170"
加上panelHeight:'auto'即可
取值问题例子:在对其取值的时候?//不能使用 $('#cc').val()//正确应该//取ID $('#cc').combobox('getValue')//取显示的name $('#cc').combobox('getText')
模糊查询若要模糊查找,就要把jquery.easyui.js文件row[opts.textField].indexOf(q)==0替换为row[opts.textField].indexOf(q)>-1,或者 添加 filter: function(q, row){ var opts = $(this).combobox('options'); return row[opts.textField].indexOf(q) == 0; }。
修改事件keydown.combo为keyup.combo就能支持火狐的中文模糊搜索。以上是网上的说法,我的是1.4.3版本
1、调整Combobox支持模糊查询,并支持从任意位置开始匹配
return row[opts.textField].toLowerCase().indexOf(q.toLowerCase()) == 0;
修改为
return row[opts.textField].toLowerCase().indexOf(q.toLowerCase()) > -1;
2、调整Combobox,以支持搜索时中文输入结束不自动触发查询
解决方案:将触发查询执行的引起事件由keydown改成 keyup $.fn.combo.defaults = $.extend({}, $.fn.textbox.defaults, {
inputEvents: { click: _952, keydown: _956, paste: _956, drop: _956 }, panelWidth: null, panelHeight: 200, panelMinWidth: null, panelMaxWidth: null, panelMinHeight: null, panelMaxHeight: null, panelAlign: "left", multiple: false, selectOnNavigation: true, separator: ",", hasDownArrow: true, delay: 200, keyHandler: {
up: function (e) {
}, down: function (e) {
}, left: function (e) {
}, right: function (e) {
}, enter: function (e) {
}, query: function (q, e) {
}
}, onShowPanel: function () {
}, onHidePanel: function () {
}, onChange: function (_983, _984) {
}
});
修改为 $.fn.combo.defaults = $.extend({}, $.fn.textbox.defaults, {
inputEvents: { click: _952, keyup: _956, paste: _956, drop: _956 }, panelWidth: null, panelHeight: 200, panelMinWidth: null, panelMaxWidth: null, panelMinHeight: null, panelMaxHeight: null, panelAlign: "left", multiple: false, selectOnNavigation: true, separator: ",", hasDownArrow: true, delay: 200, keyHandler: {
up: function (e) {
}, down: function (e) {
}, left: function (e) {
}, right: function (e) {
}, enter: function (e) {
}, query: function (q, e) {
}
}, onShowPanel: function () {
}, onHidePanel: function () {
}, onChange: function (_983, _984) {
}
});3.调整Combobox,以支持搜索时中文输入法输英文结束时带回车按钮不自动触发查询
switch (e.keyCode) {
case 38:
opts.keyHandler.up.call(_957, e);
break;
case 40:
opts.keyHandler.down.call(_957, e);
break;
case 37:
opts.keyHandler.left.call(_957, e);
break;
case 39:
opts.keyHandler.right.call(_957, e);
break;
case 13:
e.preventDefault();
opts.keyHandler.enter.call(_957, e);
return false;
case 9:
case 27:
_950(_957);
break;
default:
if (opts.editable) {
if (_958.timer) {
clearTimeout(_958.timer);
}
_958.timer = setTimeout(function () {
var q = t.combo("getText");
if (_958.previousText != q) {
_958.previousText = q;
t.combo("showPanel");
opts.keyHandler.query.call(_957, q, e);
t.combo("validate");
}
}, opts.delay);
}
}
修改为 switch (e.keyCode) {
case 38:
opts.keyHandler.up.call(_957, e);
break;
case 40:
opts.keyHandler.down.call(_957, e);
break;
case 37:
opts.keyHandler.left.call(_957, e);
break;
case 39:
opts.keyHandler.right.call(_957, e);
break;
case 13:
e.preventDefault();
if (opts.editable) {
if (_958.timer) {
clearTimeout(_958.timer);
}
_958.timer = setTimeout(function () {
var q = t.combo("getText");
if (_958.previousText != q) {
_958.previousText = q;
t.combo("showPanel");
opts.keyHandler.query.call(_957, q, e);
t.combo("validate");
}
}, opts.delay);
}
//opts.keyHandler.enter.call(_957, e);
return false;
case 9:
case 27:
_950(_957);
break;
default:
if (opts.editable) {
if (_958.timer) {
clearTimeout(_958.timer);
}
_958.timer = setTimeout(function () {
var q = t.combo("getText");
if (_958.previousText != q) {
_958.previousText = q;
t.combo("showPanel");
opts.keyHandler.query.call(_957, q, e);
t.combo("validate");
}
}, opts.delay);
}
}
本文网址:http://www.shaoqun.com/a/275499.html
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:admin@shaoqun.com。
0