
Untitled
By: a guest on
Jun 14th, 2012 | syntax:
JavaScript | size: 1.26 KB | hits: 16 | expires: Never
Ext.require([
'Ext.layout.container.Column',
'Ext.form.*',
'Ext.Panel',
'Ext.window.MessageBox'
]);
Ext.define('Example.RadioField', {
extend: 'Ext.panel.Panel',
config: {
name: 'name',
value: 'value',
boxLable: 'boxLabel'
},
constructor: function(config) {
this.callParent(this);
Ext.apply(this, config);
this.radio = new Ext.form.Radio({
name: this.name,
value: this.value,
boxLabel: this.boxLabel + ': '
});
this.field = new Ext.form.TextField({
disabled: true,
name: 'field_' + this.name
});
this.layout = 'column'; // Welche layouts gibt es
this.border = false;
this.add([{
items: this.radio,
unstyled: true,
layout: 'form'
}, {
labelWidth: 1,
layout: 'form',
unstyled: true,
item: this.field
}]);
this.subscribeEvents();
},
subscribeEvents: function() {
this.radio.on('check', this.toggleState, this);
},
toggleState: function(e, checked) {
if (checked) {
this.field.enable();
this.field.focus();
} else {
this.field.disable();
}
}
});
Ext.onReady(function() {
var radioField = Ext.create('Example.RadioField', {
renderTo: 'fi-basic',
name: 'url',
value: 'hello',
boxLabel: 'boxLabel'
});
});