가장 쉬운 방법은 필드 믹스와 함께 fieldcontainer을 확장하는 클래스에 모두 팩하는 것입니다. 다음은 예제입니다 (간단히 입력하면 완전히 테스트되지 않았습니다!). 기본 레이아웃으로 네이티브 구성 요소 만 사용하는 경우 렌더링을 다시 작성할 필요가 없다고 생각합니다.
Ext.define('Ext.ux.form.field.AdvancedPicker', {
extend: 'Ext.form.FieldContainer',
mixins: {
field: 'Ext.form.field.Field'
},
alias: 'widget.advancedpicker',
layout: 'hbox',
width: 200,
height: 22,
combineErrors: true,
msgTarget: 'side',
pickerCfg: null,
textfieldCfg: null,
initComponent: function() {
var me = this;
if (!me.pickerCfg) me.pickerCfg = {};
if (!me.textfieldCfg) me.textfieldCfg = {};
me.buildField();
me.callParent();
me.pickerField = me.down('picker')
me.textField = me.down('textfield')
me.initField();
},
//@private
buildField: function() {
var me = this;
me.items = [
Ext.apply({
xtype: 'picker',
submitValue: false, // this one shouldn't get submitted
width: 100,
flex: 2
}, me.pickerCfg),
Ext.apply({
xtype: 'textfield',
submitValue: false, // this one shouldn't get submitted
width: 80,
flex: 1
}, me.textfieldCfg)]
},
getValue: function() {
var me = this,
value;
// getting the value form the nested fields
return value;
},
setValue: function (value) {
var me = this;
// setting the values to the nested fields
},
getSubmitData: function() {
var me = this,
data = null;
// getting the value form the nested field which should get submit in formatted manner (if needed. otherwise just call getValue())
return data;
}
});
출처
2012-11-07 10:44:10
sra
'Ext.picker.Color'를 확장하려고 시도 했습니까? – Damask
Ext.picker.Color를 확장하려고하지만 사용자가 RGB 및 16 진 값을 입력 할 수 있도록 기본 색상 아래에 텍스트 상자를 배치하는 방법을 모르겠습니다. – Shekhar
** render ** 방법을 재정의해야합니다. http://docs.sencha.com/ext-js/4-1/#!/api/Ext.picker.Color-method-render – Damask