PDA

View Full Version : Ext.extend: looking for a simple sample



franck34
19 May 2010, 10:10 AM
Does an expert should show me how to make this really simple thing (just to help me to understand how it's working).

Ext.ux.form.textFieldDefaultValueFoo
Ext.ux.form.textFieldDefaultValueBar

Both are extending form.textfield with defaut value 'foo' for the first one, 'bar' for the second one.

It take 30 sec for an expert but it will be helpfull for me and helpfull for people wanted to have a clear and basic starting sample.

I know, it's not necessary to extend form.textField to set the default value, it's just to make an example of extend !

Thanks in advance community !!

Animal
19 May 2010, 10:15 AM
Never glanced at your Ext source?

franck34
19 May 2010, 10:22 AM
All the day. But it's not the purpose ;)

moegal
19 May 2010, 10:36 AM
Have you looked at:

http://www.extjs.com/learn/Tutorial:Creating_new_UI_controls

franck34
19 May 2010, 10:54 AM
Have you looked at:

http://www.extjs.com/learn/Tutorial:Creating_new_UI_controls

Since the time i'm browsing this website, the answer is NO. Thanks a lot. Not possible to take the good way without it ..

franck34
19 May 2010, 10:58 AM
I'm probably very tired AND blind lol

moegal
19 May 2010, 11:34 AM
Here is a quick example. No expert here but am learning.



Ext.ns('Ext.ux.form'); // set up Ext.ux.form namespace

/**
* @class Ext.ux.form.FooTextField
* @extends Ext.TextField
* Foo class.
*/
Ext.ux.form.FooTextField = Ext.extend(Ext.form.TextField, {
value: 'Foo',
// private
constructor: function(config){
Ext.apply( this, config );
Ext.ux.form.FooTextField.superclass.constructor.apply(this, arguments);
},
// private
initComponent: function(){
Ext.ux.form.FooTextField.superclass.initComponent.call(this);
},
// private
onRender : function(ct, position){
Ext.ux.form.FooTextField.superclass.onRender.call(this, ct, position);
}
});
Ext.reg('footextfield', Ext.ux.form.FooTextField);

steffenk
19 May 2010, 12:04 PM
i never stop posting this link :)
http://www.extjs.com/forum/showthread.php?54537-code-structure&p=259901#post259901