1

我在控制器中有一个功能。它将返回一个值。我已经在视图中调用了该函数,renderer:this.getController('test.controller.Barchart').change();但它不起作用。我得到一个错误风没有方法getController()。谁能告诉我如何正确称呼它?

4

3 回答 3

6

让视图调用控制器被认为是邪恶的本质。视图永远不应该知道控制器。我是一个使用 ExtJS 的大型项目的负责人,除了视图的 JSON 描述外,我们的视图中不允许有任何内容。寻找控制器的逻辑应该在控制器本身中。

于 2013-08-17T03:35:58.090 回答
5

请参考下面的解决方案!!!

var ControllerRef=<applicationreference>.getController(<ControllerfolderPath>.controllerName);
ControllerRef.<ControllerFunction>();

例子:

var MyApp = Ext.create('Ext.app.Application', { 
               ......
               ......
            });

var ControllerRef  =   MyApp.getController('general.ManagerController');
ControllerRef.MyFunction();

谢谢

于 2013-04-30T07:30:44.880 回答
0

试试这个:你可以把你的控制器作为一个全局变量放在你的 app.js 中,如下所示:

Ext.define('MySharedData', {
    my_Controller:Object

});

在您的控制器中:

MySharedData.my_Controller=this.getController('<ControllerfolderPath>.controllerName');

然后从您的角度调用您想要的函数:

 MySharedData.my_Controller.my_Function();
于 2013-05-01T08:16:09.793 回答