display a hidden item in a view of MVC
Here is my view, I want to retrieve the item whose id is "SRInfo" in my Combo, when "No is selected", and then set SRInfo visible:
Ext.define('FSSP.view.reqform.newReq', {
extend: 'Ext.form.Panel',
alias: 'widget.newReqForm',
...
items: [
{
xtype: 'fieldcontainer',
fieldLabel: 'Basic Information',
labelStyle: 'font-weight:bold;padding:0',
layout: 'anchor',
defaults: {
layout: '100%'
},
fieldDefaults: {
labelAlign: 'top'
},
items: [{
xtype: 'fieldcontainer',
labelStyle: 'font-weight:bold;padding:0',
layout: 'hbox',
defaultType: 'textfield',
fieldDefaults: {
labelAlign: 'top'
},
items:[{
flex: 1,
xtype: 'combo',
fieldLabel: '<font color="red">*</font> SR Open?',
allowBlank: false,
store: new Ext.data.SimpleStore({
data: [['Y', 'Yes'], ['N', 'No']],
id: 0,
fields: ['value', 'text']
}),
listeners: {
scope: this,
'select': function(combo,records){
var i = records[0].get('text');
if( i == 'No'){
el = Ext.getElement("SRInfo"); // it d开发者_开发百科oesn't work, and I tried a couple of other ways, Ext.Element.select, Ext.element.query
el.setVisible(true);
}
}
}
...
{
xtype: 'fieldcontainer',
labelStyle: 'font-weight:bold;padding:0',
**id: "SRInfo",**
layout: 'hbox',
defaultType: 'textfield',
hidden: true,
fieldDefaults: {
labelAlign: 'top'
},
items: [
{
flex: 2,
name: 'number',
fieldLabel: 'SR Reason',
allowBlank: false,
margins: '0 0 0 5'
},
{
flex: 2,
name: 'region',
fieldLabel: 'SR Comments',
allowBlank: false,
margins: '0 0 0 5'
}]
}]
},
Ext.define('FSSP.view.reqform.newReq', {
extend: 'Ext.form.Panel',
alias: 'widget.newReqForm',
...
initComponent: function() {
this.hiddenItem = Ext.create(...);
Ext.appy(this,{
items:[
{
...
listener: function(){ this.hiddentItem.show()};
...
},
{
...
},
this,hiddenItem
]
})
精彩评论