Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Model view controller 从控制器设置Triggerfield值_Model View Controller_Extjs_Extjs4 - Fatal编程技术网

Model view controller 从控制器设置Triggerfield值

Model view controller 从控制器设置Triggerfield值,model-view-controller,extjs,extjs4,Model View Controller,Extjs,Extjs4,我尝试从窗口网格绑定数据,该网格通过触发器字段单击显示。 这是我与triggerfield的表格: Ext.define('ResApp.view.group.Detail', { extend: 'Ext.window.Window', alias:'widget.groupdetail', floating: true, hidden: false, width: 450, //height: 400, resizeable: false, title: 'Detail Group', m

我尝试从窗口网格绑定数据,该网格通过触发器字段单击显示。 这是我与triggerfield的表格:

Ext.define('ResApp.view.group.Detail', {
extend: 'Ext.window.Window',
alias:'widget.groupdetail',

floating: true,
hidden: false,
width: 450,
//height: 400,
resizeable: false,
title: 'Detail Group',
modal: true,

initComponent: function() {
    var me = this;

    Ext.applyIf(me, {

        ....other config...

        items: [
            {
                xtype: 'form',
                itemId: 'groupDetailForm',
                border: false,
                layout: {
                    type: 'auto'
                },
                bodyPadding: 10,
                preventHeader: true,
                title: 'My Form',
                items: [

                    ....other items...

                    {
                        xtype: 'triggerfield',
                        padding: '0 0 5 0',
                        width: 350,
                        fieldLabel: 'Nama Kontak',
                        name: 'namaJamaah',
                        itemId: 'namaLead',
                        triggerCls: ' x-form-search-trigger',
                        onTriggerClick: function(){
                            Ext.widget('listjamaahgroup').show();
                        }
                    },

                    ....other items...

                ]
            }
        ]
    });

    me.callParent(arguments);
}});
接下来,使用网格列出数据的我的窗口:

Ext.define('ResApp.view.group.ListJamaahGroup', {
extend: 'Ext.window.Window',
alias:'widget.listjamaahgroup',

height: 400,
width: 750,
title: 'Daftar Jamaah',
modal: true,
hidden: false,
floating: true,
resizeable: false,

initComponent: function() {
    var me = this;

    Ext.applyIf(me, {
        items : [
            {
                    xtype: 'gridpanel',
                    autoScroll: true,
                    border:false,
                    title: 'Daftar Anggota',
                    itemId: 'gridAnggota',
                    preventHeader: true,
                    forceFit: true,
                    flex: 1,
                    store: 'Jamaah',
                    allowDeselect : true,
                    viewConfig: {
                        autoScroll: true
                    },
                    dockedItems: [
                        {
                            xtype: 'toolbar',
                            dock: 'top',
                            cls:'border-bottom',
                            items: [
                                {
                                    xtype: 'button',
                                    text: 'Pilih',
                                    iconCls:'edit',
                                    action: 'selectJamaahGrp',
                                    itemId: 'selectJamaahGrp'
                                },
                                {
                                    xtype: 'button',
                                    text: 'Baru',
                                    iconCls:'add'
                                }
                            ]
                        }
                    ],
                    columns: [

                    ....Grid columns...

                    ]                            
            }
        ]

    });

    me.callParent(arguments);
}});
这是我的控制器:

Ext.define('ResApp.controller.GroupDetails', {
extend: 'Ext.app.Controller',
stores: [
    'Group', 'Jamaah'
],
models: [
  'Group', 'Jamaah'
],
views:[
    'group.Detail',
    'group.ListJamaahGroup'
],
init: function(){
    this.control({
        ...

        'button[action=selectJamaahGrp]': {
            click: this.selectJamaahGrp
        },

        ...
    });
},

... other functions ...

selectJamaahGrp: function(button, e, options) {
    //windowDetail.hide();

    var grid = button.up('grid');
    if (grid) {
        var windowDetail = Ext.widget('groupdetail');
        var form = windowDetail.down('form');


        var sm = grid.getSelectionModel();
        var rs = sm.getSelection();
        if (!rs.length) {
            Ext.Msg.alert('Info', 'Pilih salah satu');
            return;
        }

        var data = grid.getSelectionModel().getSelection()[0];
        //how to setValue to triggerfield from here
    }
    button.up('listjamaahgroup').destroy();
},
batalSelClick: function(button, e, options) {
    button.up('listjamaahgroup').destroy();
}
... other functions ...})

我的问题是,我不知道如何从我的控制器设置triggerfield的值。或者还有其他方法吗?

只需在控制器中定义一个ref(
refs:[{ref:'trigger',selector:'triggerfield'}]
),然后执行
this.getTrigger().setValue()

我可能缺少一些东西,但您不能在控制器中定义一个ref(
refs:[{:'trigger',selector:'triggerfield})]
),然后执行
this.getTrigger().setValue()
?谢谢@Izhaki,添加了参考及其作品。