【问题标题】:ExtJS4 MVC: How to select button by classExtJS4 MVC:如何按类选择按钮
【发布时间】:2023-03-27 02:04:01
【问题描述】:

如果有一个网格并且我想控制(从控制器)这个网格的 tbar 中的一些按钮。

我可以找到具有 itemId 属性的按钮,但是如何按类查找按钮,以及需要使用什么类(有 baseCls、cls 等,它们不起作用)?

这是我的控制器代码:

Ext.define("Wtb.controller.Schedule",{
extend:'Ext.app.Controller',

    refs:[{
        ref:'grid',
        selector:'button'
    }],
init: function () {

    this.control({
        'button#remove':{
            click:this.Remove
        },
        'button#refresh':{
            click: this.Load
        },
        'button#save':{ //Buttons with id works fine
            click:this.Save
        },
        'button.period':{ //It can't be found, because here is the class
            click:this.changePeriod
        }
    })

这里是按钮 sn-p:

{ //Button with ID
    xtype:"button",
    itemId:'refresh',
    text:"Refresh"
},'->',{ //Button with class. I need some buttons, like this.
    xtype:"button",
    text:"Period - day",
    cls:'period',
    value:'day'
}

如何从控制器中按类查找按钮?

【问题讨论】:

    标签: javascript model-view-controller extjs


    【解决方案1】:

    查看 ComponentQuery 的文档:http://docs.sencha.com/ext-js/4-0/#!/api/Ext.ComponentQuery

    这应该会为您提供正确的按钮:

    'button[cls=period]'
    

    【讨论】:

    • cls 属性不起作用。我拿了 componentCls 并使用它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-09-01
    • 2011-03-10
    • 2011-04-17
    • 1970-01-01
    • 2020-05-21
    • 1970-01-01
    • 2017-06-30
    相关资源
    最近更新 更多