使easyui combobox控件支持上下键切换数据选项
来源:互联网 发布:双色球算法必中六红 编辑:程序博客网 时间:2024/06/02 04:01
使用combobox控件时,其操作方式为:
使用鼠标点击▼图标,显示panel后,使用鼠标点击,或者键盘的上下键来选择数据。
而录入人员习惯全键盘操作,不希望选择时还使用鼠标。其目标就是:当其获取焦点时,希望能使用键盘的上下键来选择数据。
为达到这个目标,就分析了easyui combobox的源代码,发现其设计人员已经考虑了这这种情况,只是提供的方法中限制只有当panel显示的时候才允许选择。
所以,把这个条件去掉了,就达到了目的。
具体修改内容如下:
/**
* combobox - jQuery EasyUI
*
* Licensed under the GPL:
* http://www.gnu.org/licenses/gpl.txt
*
* Copyright 2010 stworthy [ stworthy@gmail.com ]
*
* Dependencies:
* combo
*
*/
(function($) {
......
function selectPrev(target) {
var panel = $(target).combo('panel');
var values = $(target).combo('getValues');
var item = panel.find('div.combobox-item[value=' + values.pop() + ']');
if (item.length) {
// prev方法中去掉筛选:var prev = item.prev(':visible');
var prev = item.prev();
if (prev.length) {
item = prev;
}
} else {
item = panel.find('div.combobox-item:visible:last');
}
var value = item.attr('value');
setValues(target, [value]);
scrollTo(target, value);
};
function selectNext(target) {
var panel = $(target).combo('panel');
var values = $(target).combo('getValues');
var item = panel.find('div.combobox-item[value=' + values.pop() + ']');
if (item.length) {
// next方法中去掉筛选: var next = item.next(':visible');
var next = item.next();
if (next.length) {
item = next;
}
} else {
item = panel.find('div.combobox-item:visible:first');
}
var value = item.attr('value');
setValues(target, [value]);
scrollTo(target, value);
};
......
})(jQuery);
当然,也可以采用扩展的方式修改对象的行为。
- 使easyui combobox控件支持上下键切换数据选项
- 使easyui中combobox控件支持本地数据自动补全
- 上下键 切换聚焦控件
- easyui combobox插入一条数据到选项中
- easyui-combobox 动态添加选项
- easyui combobox远程数据
- easyui combobox拿数据
- easyui控件之combobox用法。
- easyUI 小技巧 easyui-combobox控件
- 为easyui combobox添加默认选项
- 为easyui combobox设置默认选项
- easyui-combobox 动态添加选项option
- easyui combobox添加清除选项按钮
- easyui select combobox 获取下拉选项值
- easyui的combobox根据拼音搜索选项
- easyUI下拉框控件easyui-combobox使用后台json文件填充数据失败的问题
- easyui中combobox 验证输入的值必须为选项框中的数据
- easyui中combobox 验证输入的值必须为选项框中的数据
- 我使用过的Linux命令之dos2unix - 将DOS格式文本文件转换成UNIX格式
- java中将一个obj对象转化为json对象
- makefile的常用方法
- 驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接 错误解决办法
- vb.net和C#.net获取字符串的字节长度
- 使easyui combobox控件支持上下键切换数据选项
- eclipse进行android,运行就提示ERROR: Unknown command 'crunch'
- Public-Key Cryptography Standards (PKCS)
- cfbs培训摘录
- 升级 _Oracle 9i、10g、11g软件下载地址大全—最新下载! WEBLOGIC 下载地址
- 第三周实验报告(4)
- aix 64
- Io 异常: The Network Adapter could not establish the connection的三种解决方法
- shell文件行尾出现^M