sw45859
12-02-2007, 12:04 PM
hi, i'm new to these forums and kinda to ext as well. awesome library first off.
this section of code is meant to be added to the ext-all.js file, it allows you to set up an external function to update another text field or whatever you want to do in that function, i'm sure it's easily done with TextField as well but i needed it for a number field so that's what i'm posting :D.
it supports every configuration that the NumberField supports so it's all the same setup with the addition of the "updateFunction" setting.
new Ext.form.NumberFieldTwin({
name: 'name',
id: 'name',
updateFunction: {your external function name}
});
Ext.form.NumberFieldTwin=Ext.extend(Ext.form.NumberField, {
updateFunction: null,
initEvents:function(){
Ext.form.NumberFieldTwin.superclass.initEvents.call(this);
var B=this.baseChars+"";
if(this.allowDecimals){
B+=this.decimalSeparator
}
if(this.allowNegative){B+="-"}
this.stripCharsRe=new RegExp("[^"+B+"]","gi");
var A=function(D){
var C=D.getKey();
if(!Ext.isIE&&(D.isSpecialKey()||C==D.BACKSPACE||C==D.DELETE)){return }
var E=D.getCharCode();
if(B.indexOf(String.fromCharCode(E))===-1){D.stopEvent()}
this.updateFunction();
};
this.el.on("keyup",A,this)
},
});
this section of code is meant to be added to the ext-all.js file, it allows you to set up an external function to update another text field or whatever you want to do in that function, i'm sure it's easily done with TextField as well but i needed it for a number field so that's what i'm posting :D.
it supports every configuration that the NumberField supports so it's all the same setup with the addition of the "updateFunction" setting.
new Ext.form.NumberFieldTwin({
name: 'name',
id: 'name',
updateFunction: {your external function name}
});
Ext.form.NumberFieldTwin=Ext.extend(Ext.form.NumberField, {
updateFunction: null,
initEvents:function(){
Ext.form.NumberFieldTwin.superclass.initEvents.call(this);
var B=this.baseChars+"";
if(this.allowDecimals){
B+=this.decimalSeparator
}
if(this.allowNegative){B+="-"}
this.stripCharsRe=new RegExp("[^"+B+"]","gi");
var A=function(D){
var C=D.getKey();
if(!Ext.isIE&&(D.isSpecialKey()||C==D.BACKSPACE||C==D.DELETE)){return }
var E=D.getCharCode();
if(B.indexOf(String.fromCharCode(E))===-1){D.stopEvent()}
this.updateFunction();
};
this.el.on("keyup",A,this)
},
});