从FormController中访问功能,即可快速创建

编程入门 行业动态 更新时间:2024-10-28 17:13:56
本文介绍了从FormController中访问功能,即可快速创建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

视图控制器将处于活动状态,但它将控制许多其他视图的一个子视图,因此我认为还有其他主动视图控制器。

The view controller will be active, but it will be controlling one sub-view of many other views, so I think there will be other active view controllers.

基本上,该表单由完全不同的调度程序创建,组件和处理程序等,视图控制器和表单之间没有直接的连接。

By on-the-fly basically the form is created by a completely different dispatcher, with components and handlers, etc. with no direct connection between the view controller and the form.

视图控制器有几个功能,我需要从以下内容获取结果:

The view controller has several functions I need to get results from:

canContinue: function (arg1) {var result = true; /*...*/ return result;} getStatus: function (arg1, arg2) {var result = 0; /* ... */ return result;}

/ * .. 。* / 表示代码省略。所以我想访问视图控制器和这些功能。以下这些线条:

/*...*/ means code omitted. So I want access to the view controller and these functions. Something along these lines:

var controller = /* how to get it? */; if (!controller.canContinue(p)) alert(controller.status(q, r));

我看到不建议以这种方式直接访问函数,所以尝试触发事件,但我似乎没有得到结果,我需要。

I read it is not recommended to access functions directly in this manner, so tried firing events, but I can't seem to get results back, which I need.

我以为我可以给视图控制器一个 itemId ,然后执行 Ext.ComponentQuery.query('#itemId'),但它似乎不起作用。我想一个视图控制器不是一个组件,是有道理的。

I thought I could give the view controller an itemId, and do Ext.ComponentQuery.query('#itemId'), but it doesn't seem to work. I guess a view controller isn't a component, makes sense.

视图控制器有一个唯一的类和别名,只有一个这些视图控制器有效一时间,如果这有帮助。

The view controller has a unique class and alias, and there will be only one of these view controllers active at a time, if that helps.

我可能错过了一些非常简单的事情。欢迎任何帮助。

I'm probably missing something really easy. Any assistance would be welcome.

推荐答案

我不太确定你的问题。这是我的理解:你有不同的看法,他们之间没有直接的关系。但是你想要达到对方视图的控制器。如果是,请检查这个小提琴: fiddle.sencha/#fiddle/urg

I am not quite sure about your question. Here is what I understand: You have different views and there is no direct relation between them. But you want to reach each other view's controller. If so, please check this fiddle: fiddle.sencha/#fiddle/urg

否则,我宁愿准备一个小提琴,显示你的问题。

Otherwise, I'd prefer you prepare a fiddle, which show your problem.

Ext.define('FirstPanel', { extend: 'Ext.panel.Panel', controller: 'FirstPanelController', layout: 'fit', itemId: 'firstPanel', items: [{ xtype: 'button', text: 'FirstPanel Button', handler: 'FirstButtonClick' }] }); Ext.define('FirstPanelController', { extend: 'Ext.app.ViewController', alias: 'controller.FirstPanelController', FirstButtonClick: function(button) { var me = this; var SecondPanelController = me.getView().mainView.down('#secondPanel').getController(); SecondPanelController.FirstButtonClick(); console.log('FirstButton Click'); }, SecondButtonClick: function() { alert('You are in FirstPanelController'); }, init: function() { var me = this; } }); Ext.define('SecondPanelController', { extend: 'Ext.app.ViewController', alias: 'controller.SecondPanelController', SecondButtonClick: function(button) { var me = this; var FirstPanelController = me.getView().up().down('#firstPanel').getController(); FirstPanelController.SecondButtonClick(); console.log('SecondPanelController'); }, FirstButtonClick: function() { alert('You are in SecondPanelController'); }, init: function() { var me = this; } }); Ext.define('SecondPanel', { extend: 'Ext.panel.Panel', controller: 'SecondPanelController', layout: 'fit', itemId: 'secondPanel', items: [{ xtype: 'button', text: 'SecondPanel Button', handler: 'SecondButtonClick' }] }); Ext.define('MainPanel', { extend: 'Ext.panel.Panel', initComponent: function() { var me = this; me.items = [ Ext.create('FirstPanel', { mainView: me }), Ext.create('SecondPanel') ] me.callParent(); } });

更多推荐

从FormController中访问功能,即可快速创建

本文发布于:2023-11-26 04:35:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1632645.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:快速   功能   FormController

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!