Skip to content

Instantly share code, notes, and snippets.

@sepulchered
Created February 27, 2013 06:21
Show Gist options
  • Save sepulchered/5045641 to your computer and use it in GitHub Desktop.
Save sepulchered/5045641 to your computer and use it in GitHub Desktop.
Ext.ux.form.AdvancedSearchField = Ext.extend( Ext.ux.form.TripleTriggerField, {
initComponent : function(){
Ext.ux.form.AdvancedSearchField.superclass.initComponent.call(this);
this.on('specialkey', function(f, e){
if(e.getKey() == e.ENTER){
this.onTrigger2Click();
}
}, this);
if (Ext.isString(this.store)) {
this.store = Ext.StoreMgr.lookup(this.store);
}
},
validationEvent:false,
validateOnBlur:false,
trigger1Class:'x-form-clear-trigger',
trigger2Class:'x-form-search-trigger',
trigger3Class:'x-form-advanced-search-trigger',
hideTrigger1:true,
width:180,
hasSearch : false,
paramName : 'search',
onTrigger1Click : function(){
if(this.hasSearch){
this.el.dom.value = '';
var o = {start: 0};
this.store.baseParams[this.paramName] = '';
this.store.reload({params:o});
this.triggers[0].hide();
this.hasSearch = false;
}
},
onTrigger2Click : function(){
var v = this.getRawValue();
if(v.length < 1){
this.onTrigger1Click();
return;
}
var o = {start: 0};
this.store.baseParams[this.paramName] = v;
this.store.reload({params:o});
this.hasSearch = true;
this.triggers[0].show();
},
onTrigger3Click: function(){
console.log('Not implemented');
}
} );
Ext.reg('advancedsearchfield', Ext.ux.form.AdvancedSearchField);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment