Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 14th, 2012  |  syntax: JavaScript  |  size: 1.26 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Ext.require([
  2.         'Ext.layout.container.Column',
  3.         'Ext.form.*',
  4.         'Ext.Panel',
  5.     'Ext.window.MessageBox'
  6. ]);
  7.  
  8. Ext.define('Example.RadioField', {
  9.         extend: 'Ext.panel.Panel',
  10.         config: {
  11.                 name: 'name',
  12.                 value: 'value',
  13.                 boxLable: 'boxLabel'
  14.         },
  15.         constructor: function(config) {
  16.                 this.callParent(this);
  17.                 Ext.apply(this, config);
  18.                
  19.                 this.radio = new Ext.form.Radio({
  20.                         name: this.name,
  21.                         value: this.value,
  22.                         boxLabel: this.boxLabel + ': '
  23.                 });
  24.                
  25.                 this.field = new Ext.form.TextField({
  26.                         disabled: true,
  27.                         name: 'field_' + this.name
  28.                 });
  29.                
  30.                 this.layout = 'column'; // Welche layouts gibt es
  31.                 this.border = false;
  32.                
  33.                 this.add([{
  34.                         items: this.radio,
  35.                         unstyled: true,
  36.                         layout: 'form'
  37.                 }, {
  38.                         labelWidth: 1,
  39.                         layout: 'form',
  40.                         unstyled: true,
  41.                         item: this.field
  42.                 }]);
  43.                
  44.                 this.subscribeEvents();
  45.         },
  46.        
  47.         subscribeEvents: function() {
  48.                 this.radio.on('check', this.toggleState, this);
  49.         },
  50.         toggleState: function(e, checked) {
  51.                 if (checked) {
  52.                         this.field.enable();
  53.                         this.field.focus();
  54.                 } else {
  55.                         this.field.disable();
  56.                 }
  57.         }
  58. });
  59.  
  60. Ext.onReady(function() {
  61.  
  62.         var radioField = Ext.create('Example.RadioField', {
  63.                 renderTo: 'fi-basic',
  64.                 name: 'url',
  65.                 value: 'hello',
  66.                 boxLabel: 'boxLabel'
  67.         });
  68. });