简体   繁体   English

Extjs 4 MVC:通过控制器在视图中启用/禁用停靠的项目按钮

[英]Extjs 4 MVC: Enable/Disable Docked Item Button in View Via Controller

I have an MVC app in Extjs 4 which has a View (extending Ext.panel.Panel ) that contains dockedItems : 我在Extjs 4中有一个MVC应用程序,该应用程序具有一个包含dockedItems的View(扩展Ext.panel.Panel ):

            dockedItems: [{
            dock: 'top',
            xtype: 'toolbar',
            items: [{
                text: 'Check Related Site',
                action: 'viewinrelatedsite',
            }, //...

I'm picking up the action on this button over in the control function in my Controller: 我正在控制器的control功能中对该按钮进行action

    init: function() {
    this.control({
        'statusupdateform button[action=viewinrelatedsite]': {
            click: this.viewInrelatedSite
        }, //...

Then of course I have a function in the same Controller which handles the button. 然后,当然我在同一控制器中有一个处理按钮的功能。 I'm using a template in the View, and I have a formatter (also in the View) which tests for whether the field I need is available ( if (!myField)... ), which I could use to enable the button. 我在视图中使用模板,并且有一个格式化程序(也在视图中),用于测试所需的字段是否可用( if (!myField)... ), 可以用来启用按钮。 That part works fine. 那部分工作正常。

What I'm stuck on is how to pass the info about the presence of the field var from the View to the Controller such that the button can be enabled/disabled, and how to pass the contents of this field variable as well. 我所坚持的是如何从View向Controller传递有关字段var存在的信息,以便可以启用/禁用按钮,以及如何传递该字段变量的内容。

Thanks very much for any advice! 非常感谢您的任何建议!

@Matt, @马特

You can have a public property inside your view or a public method inside the view which the controller can call on the view reference to inspect/pass the variable value. 您可以在视图内部拥有一个公共属性,或者在视图内部拥有一个公共方法,控制器可以在视图引用上调用该方法来检查/传递变量值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM