使用控制器将参数从视图发送到Sencha Touch 2中的其他参数

Mul*_*tut 3 model-view-controller sencha-touch-2

我只是从Sencha Touch 1.x迁移到Sencha Touch 2,我找不到在视图之间传递参数的方法.

让我说我必须观看:放置(包含所有地方的列表)PeopleAtPlace(每个地方的人员列表)

现在我需要做的是将按下的地方的id传递给peopleatplace视图,以便它可以让人们获得该特定视图.

我一直在阅读Sencha的文档,但这对我来说很困惑.

有人可以帮帮我吗?代码片段对我很有帮助.

tpo*_*yak 7

控制器可以是不同视图之间的粘合剂.我不知道你究竟有什么样的观点,但以下代码可以作为基础:

Ext.define('MyApp.controller.TestController', {
    extend : 'Ext.app.Controller',

    config : {
        views : [  // you need to list all views your controller will use
            'Place', 
            'PeopleAtPlace'
        ],

        refs : {
            place : 'place',  // ComponentQuery used to find the view e.g. xtype, id, etc of the view 
            peopleAtPlace : 'peopleAtPlace'
        },

        control : {
            place : {
                select : 'onPlaceSelected' // use the appropriate event 
            }
        }
    },

    onPlaceSelected : function (view, record) {
        var peopleAtPlaceView = this.getPeopleAtPlace(); // generated by Sencha from the ref property

        // now you have the reference to the target view, you can put your logic here
        peopleAtPlaceView.doSomething(record);
    }
});
Run Code Online (Sandbox Code Playgroud)