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
Extjs 试图通过initComponent将参数传递给项数组_Extjs_Extjs4 - Fatal编程技术网

Extjs 试图通过initComponent将参数传递给项数组

Extjs 试图通过initComponent将参数传递给项数组,extjs,extjs4,Extjs,Extjs4,我有一个包含组合的表单,我正在尝试找出一种将组合值传递给组合小部件的简单方法 基本上,我将数组传递到我的表单,如下所示: var contentPanel = Ext.create('MyForm', { countryCodesForCombo: _this.countryCodesForCombo, }); 这意味着数据通过initComponent方法获得 Ext.define('MyForm', { extend: 'Ext.form.Panel

我有一个包含组合的表单,我正在尝试找出一种将组合值传递给组合小部件的简单方法

基本上,我将数组传递到我的表单,如下所示:

    var contentPanel = Ext.create('MyForm', {
        countryCodesForCombo: _this.countryCodesForCombo,
    });
这意味着数据通过initComponent方法获得

Ext.define('MyForm', {
    extend: 'Ext.form.Panel',

    initComponent : function (){

        var cCodes = this.countryCodesForCombo;

        this.callParent();
    },
    items: [
        {
            fieldLabel: 'Hi',
            xtype: 'combobox',
            name: 'land',
            displayField:'name',
            store: {
                fields: ['name'],
                data: this.countryCodesForCombo // <--- want to get country codes somehow here
            }
        }
    ]
});
Ext.define('MyForm'{
扩展:“Ext.form.Panel”,
initComponent:函数(){
var cCodes=this.countryCodesForCombo;
这是callParent();
},
项目:[
{
fieldLabel:'嗨',
xtype:“组合框”,
名称:'土地',
显示字段:'name',
商店:{
字段:['name'],

数据:this.countryCodesForCombo/你的商店看起来不太对劲。你必须创建一个商店对象

这将有助于:

Ext.define('MyForm', {
    extend: 'Ext.form.Panel',

    initComponent : function (){

        this.store = Ext.create('Ext.data.Store', {
            fields: ['name'],
            data: this.countryCodesForCombo
        });

        Ext.apply(this, {

                    items: [{

                        fieldLabel: 'Hi',
                        xtype: 'combobox',
                        queryMode: 'local',
                        name: 'land',
                        displayField:'name',
                        store: this.store                    
                    }]
        });

        this.callParent();
    },

});

这里还有一个小链接:

我的商店还可以。我只是想知道是否有更干净的方法将值传递给项目。使用Ext.apply(这个…)对我来说似乎有点混乱。我认为
Ext.apply(这个,{..})
如果不经常混合,也可以。但我也很头疼,直到我习惯了。想想计算的顺序。在传递给定义对象之前,需要计算对象的整个RHS。该类不存在,更不用说实例了。