当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - 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:

 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:

 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. 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.

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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: