op.vini
5 Nov 2009, 11:57 AM
New searchField.js with no bugs and new methods and property.
/*
* Ext JS Library 2.0.2
* Copyright(c) 2006-2008, Ext JS, LLC.
* licensing@extjs.com
*
* http://extjs.com/license
*
# modificado por Vinícius Nunes Lage
# estagiário da Câmara Municipal de Ouro Preto
*
*/
Ext.app.SearchField = Ext.extend(Ext.form.TwinTriggerField, {
initComponent : function(){
Ext.app.SearchField.superclass.initComponent.call(this);
this.on('specialkey', function(f, e){
if(e.getKey() == e.ENTER){
this.onTrigger2Click();
}
}, this);
},
validationEvent:false,
validateOnBlur:false,
trigger1Class:'x-form-clear-trigger',
trigger2Class:'x-form-search-trigger',
hideTrigger1:true,
width:180,
hasSearch : false,
paramName : 'query',
params: {},
beforeClear: function(){},
afterClear: function(){},
beforeSeach: function(){},
afterSeach: function(){},
onTrigger1Click : function(){
if(this.hasSearch){
this.el.dom.value = '';
//this.store.baseParams = this.store.baseParams || {};
this.store.baseParams[this.paramName] = '';
if(this.beforeClear) this.beforeClear();
this.store.reload({params: this.params, callback: this.afterClear });
this.triggers[0].hide();
this.hasSearch = false;
}
},
onTrigger2Click : function(){
var v = this.getRawValue();
if(v.length < 1){
this.onTrigger1Click();
return;
}
//this.store.baseParams = this.store.baseParams || {};
this.store.baseParams[this.paramName] = v;
if(this.beforeSearch) this.beforeSearch();
this.store.reload({params: this.params, callBack: this.afterSearch });
this.hasSearch = true;
this.triggers[0].show();
}
});
With this new code, you can use the methods: beforeClear(), afterClear(), beforeSearch(), afterSearch() and add params to your searchField.
I packed a few bugs too, show in the commented lines.
;)
/*
* Ext JS Library 2.0.2
* Copyright(c) 2006-2008, Ext JS, LLC.
* licensing@extjs.com
*
* http://extjs.com/license
*
# modificado por Vinícius Nunes Lage
# estagiário da Câmara Municipal de Ouro Preto
*
*/
Ext.app.SearchField = Ext.extend(Ext.form.TwinTriggerField, {
initComponent : function(){
Ext.app.SearchField.superclass.initComponent.call(this);
this.on('specialkey', function(f, e){
if(e.getKey() == e.ENTER){
this.onTrigger2Click();
}
}, this);
},
validationEvent:false,
validateOnBlur:false,
trigger1Class:'x-form-clear-trigger',
trigger2Class:'x-form-search-trigger',
hideTrigger1:true,
width:180,
hasSearch : false,
paramName : 'query',
params: {},
beforeClear: function(){},
afterClear: function(){},
beforeSeach: function(){},
afterSeach: function(){},
onTrigger1Click : function(){
if(this.hasSearch){
this.el.dom.value = '';
//this.store.baseParams = this.store.baseParams || {};
this.store.baseParams[this.paramName] = '';
if(this.beforeClear) this.beforeClear();
this.store.reload({params: this.params, callback: this.afterClear });
this.triggers[0].hide();
this.hasSearch = false;
}
},
onTrigger2Click : function(){
var v = this.getRawValue();
if(v.length < 1){
this.onTrigger1Click();
return;
}
//this.store.baseParams = this.store.baseParams || {};
this.store.baseParams[this.paramName] = v;
if(this.beforeSearch) this.beforeSearch();
this.store.reload({params: this.params, callBack: this.afterSearch });
this.hasSearch = true;
this.triggers[0].show();
}
});
With this new code, you can use the methods: beforeClear(), afterClear(), beforeSearch(), afterSearch() and add params to your searchField.
I packed a few bugs too, show in the commented lines.
;)