【问题标题】:Extjs5: How to query a component by various propertiesExtjs5:如何通过各种属性查询组件
【发布时间】:2014-06-02 21:07:14
【问题描述】:

给定一个这样的组件:

{xtype: 'textfield', name: 'title', fieldLabel: 'Title', autoFocus: true}

是否可以查询任意容器(例如窗口)中具有autoFocus 属性的所有项目,以在其上调用.focus(...) 方法?

试过了……

'[autoFocus]'

'*[autoFocus]'

'*[autoFocus=true]'

...与component.downExt.ComponentQuery.query(和其他人),但没有运气。

【问题讨论】:

    标签: javascript extjs extjs5


    【解决方案1】:

    Ext.ComponentQuery.query('textfield[autoFocus]') 应该可以工作,前提是文本字段已实例化。

    【讨论】:

    • 好的,我找到了解决方案。查询本身不是问题!它可以正常工作。如果我在窗口的 initComponent() 方法中查询组件(在 this.callParent(arguments) 之后),由于某种原因找不到该组件。 If I hook myself into the 'show'-event.focus() 操作有效。
    • 是的,在initComponent 期间,它们可能还没有被实例化。
    猜你喜欢
    • 1970-01-01
    • 2018-05-04
    • 1970-01-01
    • 1970-01-01
    • 2013-05-06
    • 2011-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多