私は次に行う必要があります:いくつかのボタンがあります。いずれかのボタンを押すとフォームの状態が変わるので、いくつかのボタンが見えなくなります。 私は、コンストラクタから呼び出すとき、私はextJSのコンポーネントを塗り直す
Loyalty.company.CompanyEditForm = Ext.extend(Loyalty.tools.AdvancedForm,
{
defaultConfig:{
......
currentState: 'READONLY'
// EDIT, CREATE, CREATE_EDIT
},
constructor:function (config) {
Ext.apply(config, this.defaultConfig);
config['owner'] = this;
config['items'] = [];
config['items'] = this.createItems(config);
config['buttons'] = this.createButtons(config);
Loyalty.company.CompanyEditForm.superclass.constructor.call(this, config);
this.loadCompany(config['jsonCompany']);
this.renderingView(config);// here it's ok
},
....
renderingView:function (config){
if (config.currentState == 'READONLY'){
this.items.items[0].disabled = false;
Ext.ComponentQuery.query('#cardNumber')[0].disabled = true;
Ext.ComponentQuery.query('#btnEdit')[0].hidden = false;
Ext.ComponentQuery.query('#btnRewrite')[0].hidden = true;
Ext.ComponentQuery.query('#btnSubmit')[0].hidden = true;
Ext.ComponentQuery.query('#btnCancel')[0].hidden = false;
} else if (config.currentState == 'EDIT'){
this.items.items[0].disabled = false;
Ext.ComponentQuery.query('#cardNumber')[0].disabled = false;
Ext.ComponentQuery.query('#btnEdit')[0].hidden = true;
Ext.ComponentQuery.query('#btnRewrite')[0].hidden = true;
Ext.ComponentQuery.query('#btnSubmit')[0].hidden = false;
Ext.ComponentQuery.query('#btnCancel')[0].hidden = false;
} else if (config.currentState == 'CREATE'){
Ext.ComponentQuery.query('#cardNumber')[0].disabled = false;
Ext.ComponentQuery.query('#btnEdit')[0].hidden = true;
Ext.ComponentQuery.query('#btnRewrite')[0].hidden = false;
Ext.ComponentQuery.query('#btnSubmit')[0].hidden = false;
Ext.ComponentQuery.query('#btnCancel')[0].hidden = false;
}
this.owner.doComponentLayout()
return null;
},
createButtons:function (config, form) {
return [
{
id: 'btnEdit',
text:Loyalty.messages['company.edit.fields.edit'],
handler:function() {
config.currentState = 'EDIT';
config.owner.renderingView(config)
}
} ,
{
xtype:'button',
id: 'btnRewrite',
text:Loyalty.messages['company.edit.fields.rewrite'],
handler:function() {
config.currentState = 'READONLY';
config.owner.renderingView(config)
}
},
{
xtype:'button',
id: 'btnSubmit',
text:Loyalty.messages['company.edit.fields.submit'],
handler:function() {
config.currentState = 'CREATE_EDIT';
config.owner.renderingView(config)
}
},
{
xtype:'button',
id: 'btnCancel',
text:Loyalty.messages['company.edit.fields.cancel'],
handler:function() {
if (config.currentState == 'EDIT' || config.currentState == 'CREATE_EDIT'){
config.currentState = 'READONLY';
config.owner.renderingView(config)
}
}
}
];
},
....
}
);
機能renderingViewの中華鍋良い次のコードを書きました。しかし、ボタンメソッドから呼び出されると、何も起こりません。変更するボタンの状態(非表示)。 再ペイントの問題
答えDmitryB – yaroslavTir