フィールドコンテナ内にあるテキストフィールドの値を設定できません。「フィールドコンテナ」内にある「テキストフィールド」の値とその他の構成を設定したい。したがって、基本的には、サーバーから受け取るテキストフィールドの構成を次のように設定します:フィールドコンテナである私のカスタムコントロール。組み込みの textConfig を使用する値 config を除いて、他のすべての構成が適用されます。以下は私のコードです:
Ext.define('PTextField', { extend: 'Ext.form.FieldContainer',
alias: 'widget.ptextfield',
requires: ['Ext.form.TextField', 'Ext.Img'],
width: 170,
fieldLabel: 'Empty Label',
labelAlign: 'top',
layout: {
type: 'hbox'
},
BLANK_IMAGE_URL: '',
constructor: function (config) {
this.callParent(arguments);
Ext.apply(this.down('textfield'), this.textConfig);
Ext.apply(this.down('image'), this.imgConfig);
}, // eo function constructor
initComponent: function () {
var me = this;
this.textBox = this.createTextField();
this.imageBox = this.createImagefield();
this.items = [this.imageBox, this.textBox];
this.callParent(arguments);
}, //eo initComponent
createTextField: function () { return {xtype: 'textfield'} },
createImagefield: function () { return { xtype: 'image', height: 20, width: 20} }
});
var fname = Ext.create('PTextField', {
fieldLabel: 'First Name',
textConfig: { value: 'Hello World', allowBlank: false, readOnly: true, maxLength: 4, width: 100 },
imgConfig: { src: 'http://www.sencha.com/img/20110215-feat-html5.png' }
});
fname.render(Ext.getBody());
私はextjs 4.1を使用しています。どんな助けでも大歓迎です。