Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/391.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Extjs4 fieldset.show()和fieldset.hide()不是函数问题_Javascript_Extjs4 - Fatal编程技术网

Javascript Extjs4 fieldset.show()和fieldset.hide()不是函数问题

Javascript Extjs4 fieldset.show()和fieldset.hide()不是函数问题,javascript,extjs4,Javascript,Extjs4,我对字段集显示和隐藏函数有问题。 在我的应用程序的左侧,我有一个带有change listener的组合框。在右边,我有几个不同的文本字段,它们根据combobox中选择的值显示和隐藏。 每个hide和show函数都与字段集一起工作,但是如果我不能显示/隐藏字段集。字段集引用可见,我可以使用console.log()函数列出此组件 这是我的一段代码: var rigthPanelLeftContainer = { flex: 1, minWidth: 200,

我对字段集显示和隐藏函数有问题。 在我的应用程序的左侧,我有一个带有change listener的组合框。在右边,我有几个不同的文本字段,它们根据combobox中选择的值显示和隐藏。 每个hide和show函数都与字段集一起工作,但是如果我不能显示/隐藏字段集。字段集引用可见,我可以使用console.log()函数列出此组件

这是我的一段代码:

var rigthPanelLeftContainer = {
        flex: 1,
        minWidth: 200,
        defaults: {
            xtype: 'textfield',
            minWidth: 180,
            anchor: '100%'
        },
        items: [
//some working textfields here 
{

      xtype: 'fieldset',
      labelWidth: 160,
      anchor: '100%',
      height: 40,
      itemId: 'remarkId',
      title: 'title'],
      hidden : !ifHideIt, //boolean
                    items: [{
           xtype: 'text',
           height: 25,
           text: 'sometext']
        }]
 }
]};

 var comboBoxConnectors = {
        xtype: 'combobox',
        fieldLabel: Ext.translations.map['field.label.common'],
        store: Ext.state.Manager.get('conTypes'),
        editable: false,
        queryMode: 'local',
        name: 'conType',
        itemId: 'conTypeField',
        value: connObj === null ? conTypes[0] : connObj.type,
        labelWidth: 160,
        anchor: '100%',
        listeners: {
            change: function(obj, newValue, oldValue) {

             //many hide/show working on textfield functions

             var remarkId = me.query('#remarkId');
             console.log(remarkId); //returns my fieldset element
             remarkId.hide(); //returns remarkId.hide is not a function
        }
 }
 }

我真的需要你们的帮助伙计们,这有什么问题吗

在代码中,有一条注释说me.query(“#remarkId”)返回字段集元素。这在技术上是不正确的。假设me.query()是一个组件查询,您实际上得到的是一个匹配组件的数组。因此,您将得到未定义的函数错误,因为数组没有hide()方法。如果访问数组中的第一个元素,然后调用hide()方法,它应该可以工作

但是,你也应该考虑一下这有点不同。您可以使用内置的遍历方法来查找正确的组件,而不是使用query()获取元素数组(可能总是一个,但不一定是…)。例如,假设combobox和fieldset都是同一表单面板的子项,可以执行如下操作:mycombobox.up('form').down('fieldset#remarkId')。这基本上指示代码向上遍历组件层次结构到最近的表单,然后向下钻取到表单的第一个子体,该表单是一个itemId为“remarkId”的字段集。因此,这只会给您一个组件,因此您不必费心从组件数组中访问组件