2013-08-05 4 views
-1

personne, s'il vous plaît aidez-moi avec le composant créé pour ExtJS 4.2composant personnalisé ExtJS, fonctionne pas setValue

Ext.define('mycomponent', { 
    extend:'Ext.form.field.Display', 
    alias: 'widget.mycomponent', 

    initComponent: function() { 
     this.setValue("some value") // not setup 
     this.callParent(arguments); 
     console.log(this) 
    }, 

}) 

i essayer

Ext.getCmp(this.id).setValue("some") 

mais objet html n'existent pas, les événements beforeRender E.T.C. ne pas courrir. comment je peux définir la valeur?

Répondre

0

Voici un exemple complet, testé avec 4.2.1.

Ext.define('Foo', { 
    extend:'Ext.form.field.Display', 
    alias: 'widget.mycomponent', 

    initComponent: function() { 
     this.setValue("some value") // not setup 
     this.callParent(arguments); 
    } 
}) 

Ext.onReady(function() { 

    new Foo({ 
     renderTo: document.body 
    }) 

}); 
+0

Si je définis la propriété "name", comment puis-je l'obtenir sur la méthode initComponent? –

+0

'var nom = this.name;' –

+0

mais j'ai besoin d'obtenir la valeur du nom, ce champ dans le formulaire, et je lie la forme du backend (ajax) –

0

Vous devez définir les méthodes getValue() et setValue() dans votre constructeur pour fonctionner.

getValue: function() { 
     var me = this, 
      value; 
     return value; 
    } 

    setValue: function (value) { 
     var me = this; 

// Example only should't work as it is 
     me.displayField.setValue(value); 
    } 
Questions connexes