PDA

View Full Version : Add Listener initComponent



vivek.pothagoni
9 Mar 2014, 8:16 AM
I am a Documentum xcp 2 Developer, ExtJs UI we create using a designer and only we have option to set init value to components. I can call a function on initial value, so I am falling a top container and added "afterrender" listerner.

I am tring to achive is ... after component is render, I want to add listener and strick user keying "-" hyphen in the number field.

Ext.namespace("glm.xcp.functions.validation");
glm.xcp.functions.validation.onlyAlpha = function(fieldLabel){

var topPageContainer = Ext.ComponentQuery.query("component[xcpId=column_box1]")[0];
console.log('Before Render ...');

topPageContainer.addListener(
"afterrender",
function(){
console.log('After Render Called... ');
var textfield = Ext.ComponentQuery.query("textfield[xcpId="+fieldLabel+"]")[0];
console.log('Text Field: '+textfield.getValue());

textfield.addListener(
"keypress",
function(field, newValue, oldValue, opts){
textfield.setValue(newValue.replace(/[^a-zA-Z]/g,''));
});
});
};

Thanks in advance

JIMECKELS
12 Mar 2014, 8:19 PM
Use the text field's regex mask to restrict input, and perform validation