수식을 약간 수정하고 AL || AK 논리를 비활성화 된 속성 대신 hideAlabama
수식으로 옮겼습니다. 이렇게하면 여러 수식 평가가 예상대로 작동하지 않는 것처럼 보였으므로 hidden
속성을 단일 수식 계산으로 유지합니다.
Ext.application({
name : 'Fiddle',
launch : function() {
}
});
var states = Ext.create('Ext.data.Store', {
fields: ['abbr', 'name'],
data : [
{"abbr":"AL", "name":"Alabama"},
{"abbr":"AK", "name":"Alaska"},
{"abbr":"AZ", "name":"Arizona"}
]
});
Ext.define('My.ViewModel', {
extend: 'Ext.app.ViewModel',
alias: 'viewmodel.myviewmodel',
formulas: {
hideAlabama: function(get) {
return get('comboboxvalue') === 'AL' || get('comboboxvalue') === 'AK';
},
hideAlaska: function(get) {
return get('comboboxvalue') === 'AK';
},
hideArizona: function(get) {
return get('comboboxvalue') === 'AZ';
}
}
});
Ext.create('Ext.form.Panel', {
title: 'Sign Up Form',
width: 300,
height: 230,
bodyPadding: 10,
margin: 10,
layout: {
type:'anchor',
align: 'stretch'
},
viewModel:{
type: 'myviewmodel'
},
items: [{
xtype: 'combobox',
fieldLabel: 'Choose State',
store: states,
queryMode: 'local',
displayField: 'name',
valueField: 'abbr',
reference:'combobox',
bind: {
value: '{comboboxvalue}'
}
},{
xtype: 'textfield',
fieldLabel: 'If Alabama, hide',
bind: {
hidden: '{hideAlabama}'
}
},{
xtype: 'textfield',
fieldLabel: 'If Alaska, hide',
bind: {
hidden: '{hideAlaska}'
}
},{
xtype: 'textfield',
fieldLabel: 'If Arizona, hide',
bind: {
hidden: '{hideArizona}'
}
}],
renderTo: Ext.getBody()
});
감사합니다. 당신의 솔루션은 잘 작동합니다. – josei
그것은 당신을 위해 일해서 다행입니다. 기회가 생겼을 때 대답을 받아 들인 것으로 표시하십시오. –