我正在 ExtJs 4.2 中构建一个 MVC 应用程序,并且有一个窗口和一个表单面板。
表单面板有几个我想显示/隐藏的隐藏文本字段。
当我运行这个命令时:
Ext.getCmp('PartsSell').show();
或
Ext.getCmp('PartsSell').setVisible(true);
甚至
Ext.widget('ObjectForm').getForm().findField('PartsSell').setVisible(true);
什么都没发生!!
这是表单面板片段:
Ext.define('crm.view.ObjectForm', {
extend : 'Ext.form.Panel',
header : false,
alias : 'widget.ObjectForm',
url : 'action.php',
id : "ObjectForm",
defaultType : 'textfield',
initComponent: function() {
Ext.apply(this, {
items : [
{
fieldLabel : 'label',
labelWidth : 115,
hidden : true,
allowBlank : true,
name : 'PartsSell',
itemId : 'PartsSell',
xtype : 'textfield',
vtype : 'DigitsVtype',
width : 150,
padding : '0 0 0 15'
},
/* other stuff */]
} );
this.callParent(arguments);
}
} );
FF/chrome 控制台表现得好像一切正常。
如果我将“隐藏”参数设置为“假”,则会显示该字段。
根据 Tarabass 和 Drake 的建议:
我已经更改了 itemId
上的 id
。
现在我可以通过
触发字段Ext.ComponentQuery.query('#PartsSell')[0].hide()/.show();
最佳答案
将 id: 'PartsSell'
更改为 itemId: 'PartsSell'
。
使用选择器 '#PartsSell'
选择组件。
然后使用 setHidden(false)
方法(由 config system 生成)将 hidden 设置为 false。
类似于:
Ext.ComponentQuery.query('#PartsSell')[0].setHidden(false);
关于javascript - ExtJs:无法在表单中显示字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32161105/