Ext Combox模糊匹配扩展
来源:互联网 发布:hadoop入门 知乎 编辑:程序博客网 时间:2024/04/28 23:34
MyComboBox = Ext.extend(Ext.form.ComboBox, {
initList : function(){
MyComboBox.superclass.initList.call(this);
if(this.clearable){
var combox = this;
var cls = 'x-combo-list';
this.footer = this.list.createChild({
cls : cls + '-ft'
});
this.spaceR = new Ext.Toolbar({
items : [
'->',
{
iconCls : 'bico_btnqk',
text : '清空',
handler : function(){
combox.setText('','');
combox.collapse();
}
}
],
renderTo : this.footer
});
this.assetHeight += this.footer.getHeight();
}
this.store.load();
},
setText : function(text, value){
this.lastSelectionText = text;
if(this.hiddenField){
this.hiddenField.value = value;
}
Ext.form.ComboBox.superclass.setValue.call(this, text);
this.value = value;
},
getValue : function(){
return typeof this.value != 'undefined' ? this.value : '';
},
getText : function(){
return typeof this.lastSelectionText != 'undefined' ? this.lastSelectionText : '';
},
doQuery : function(q, forceAll){
if(q === undefined || q === null){
q = '';
}
var qe = {
query : q,
forceAll : forceAll,
combo : this,
cancel : false
};
if(this.fireEvent('beforequery',qe) === false || qe.cancel){
return false;
}
q = qe.query;
forceAll = qe.forceAll;
if(forceAll === true || (q.length >= this.minChars)){
if (this.editable === true){
this.store.baseParams[this.queryParam] = q;
this.store.load({
params: this.getParams(q)
});
this.expand();
}else{
if(this.lastQuery !== q){
this.lastQuery = q;
if(this.mode == 'local'){
this.selectedIndex = -1;
if(forceAll){
this.store.clearFilter();
}else{
this.store.filter(this.displayField, q);
}
this.onLoad();
}else{
this.store.baseParams[this.queryParam] = q;
this.store.load({
params: this.getParams(q)
});
this.expand();
}
}else{
this.selectedIndex = -1;
this.onLoad();
}
}
}
},
listeners : {
'beforequery' : function(e){
var combo = e.combo;
if(!e.forceAll){
var input = e.query;
// 检索的正则
var regExp = new RegExp(".*" + input + ".*");
// 执行检索
combo.store.filterBy(function(record,id){
// 得到每个record的项目名称值
var text = record.get(combo.displayField);
return regExp.test(text);
});
combo.expand();
return false;
}
}
}
});
var qMaterielInfoStore = new Ext.data.JsonStore({
url : '../../../dfo/com_web/sys/Common/getMaterielInfo.do',
root : 'ROOT',
totalProperty : 'TOTALCOUNT',
id : 'materielid',
fields : ['materielid','shortname','objecttype'],
sortInfo : {field : 'materielid', direction : 'ASC'},
baseParams : {
'objecttype' : "0",
'dataFields' : escape('materielid,shortname,objecttype')
}
});
var qMaterielInfo = new MyComboBox({
id : 'qMaterielInfo',
name : 'qMaterielInfo',
fieldLabel : '物料名称',
store : qMaterielInfoStore,
valueField : 'materielid',
displayField : 'shortname',
lazyRender : true,
triggerAction : 'all',
anchor : '100%',
editable : true,
clearable : true
});
initList : function(){
MyComboBox.superclass.initList.call(this);
if(this.clearable){
var combox = this;
var cls = 'x-combo-list';
this.footer = this.list.createChild({
cls : cls + '-ft'
});
this.spaceR = new Ext.Toolbar({
items : [
'->',
{
iconCls : 'bico_btnqk',
text : '清空',
handler : function(){
combox.setText('','');
combox.collapse();
}
}
],
renderTo : this.footer
});
this.assetHeight += this.footer.getHeight();
}
this.store.load();
},
setText : function(text, value){
this.lastSelectionText = text;
if(this.hiddenField){
this.hiddenField.value = value;
}
Ext.form.ComboBox.superclass.setValue.call(this, text);
this.value = value;
},
getValue : function(){
return typeof this.value != 'undefined' ? this.value : '';
},
getText : function(){
return typeof this.lastSelectionText != 'undefined' ? this.lastSelectionText : '';
},
doQuery : function(q, forceAll){
if(q === undefined || q === null){
q = '';
}
var qe = {
query : q,
forceAll : forceAll,
combo : this,
cancel : false
};
if(this.fireEvent('beforequery',qe) === false || qe.cancel){
return false;
}
q = qe.query;
forceAll = qe.forceAll;
if(forceAll === true || (q.length >= this.minChars)){
if (this.editable === true){
this.store.baseParams[this.queryParam] = q;
this.store.load({
params: this.getParams(q)
});
this.expand();
}else{
if(this.lastQuery !== q){
this.lastQuery = q;
if(this.mode == 'local'){
this.selectedIndex = -1;
if(forceAll){
this.store.clearFilter();
}else{
this.store.filter(this.displayField, q);
}
this.onLoad();
}else{
this.store.baseParams[this.queryParam] = q;
this.store.load({
params: this.getParams(q)
});
this.expand();
}
}else{
this.selectedIndex = -1;
this.onLoad();
}
}
}
},
listeners : {
'beforequery' : function(e){
var combo = e.combo;
if(!e.forceAll){
var input = e.query;
// 检索的正则
var regExp = new RegExp(".*" + input + ".*");
// 执行检索
combo.store.filterBy(function(record,id){
// 得到每个record的项目名称值
var text = record.get(combo.displayField);
return regExp.test(text);
});
combo.expand();
return false;
}
}
}
});
var qMaterielInfoStore = new Ext.data.JsonStore({
url : '../../../dfo/com_web/sys/Common/getMaterielInfo.do',
root : 'ROOT',
totalProperty : 'TOTALCOUNT',
id : 'materielid',
fields : ['materielid','shortname','objecttype'],
sortInfo : {field : 'materielid', direction : 'ASC'},
baseParams : {
'objecttype' : "0",
'dataFields' : escape('materielid,shortname,objecttype')
}
});
var qMaterielInfo = new MyComboBox({
id : 'qMaterielInfo',
name : 'qMaterielInfo',
fieldLabel : '物料名称',
store : qMaterielInfoStore,
valueField : 'materielid',
displayField : 'shortname',
lazyRender : true,
triggerAction : 'all',
anchor : '100%',
editable : true,
clearable : true
});
- Ext Combox模糊匹配扩展
- EXT COMbox 任意字符模糊匹配(单行)
- Ext combobox 动态模糊匹配
- Ext combobox 动态模糊匹配
- EXT Ext combobox 动态模糊匹配
- Ext.Net 1.x_Ext.Net.Combox 实现模糊异步查询
- EXT Combox
- winform实现combox控件自动匹配查找,模糊查询功能
- Ext.net ComboBox模糊匹配store数据
- Combox 扩展
- Ext的Combox
- Ext.net combox 联动
- Ext Combox 分页
- Ext的Combox
- 正则表达式全字不区分大小写模糊匹配(EXT)
- combox自动匹配
- combox自动匹配功能
- mfc Combox扩展类
- linux下运行Qt出现cannot find -lGL和collect2: ld returned 1 exit status解决方法
- Android使用笔记--存储空间管理
- Java通过TCP实现聊天功能
- 成都东软OJ代码
- git 忽略文件
- Ext Combox模糊匹配扩展
- MySql模糊查询like通配符使用详细介绍
- Eclipse中安装Maven插件
- 【初学】UI控件学习笔记-UIButton按钮控件详细介绍
- SOLR4.4中使用IKAnalyzer
- 添加新硬盘并创建文件系统(Vmware 虚拟机)
- Linux V4L2 摄像头视频采集
- APCS
- 在CSS中 ID与Class的区别