Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.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 Extjs4没有从存储加载多个()关系';s';数据';财产_Model_Extjs4_Extjs - Fatal编程技术网

Model Extjs4没有从存储加载多个()关系';s';数据';财产

Model Extjs4没有从存储加载多个()关系';s';数据';财产,model,extjs4,extjs,Model,Extjs4,Extjs,Extjs4存储类的data属性描述了对象层次结构。我把它作为我的存储的数据属性,因为数据是静态的;无需额外调用服务器来填充存储。我以前也这样做过,但这次我的hasMany关系没有得到改善。我已经尝试了各种方法来解决这个问题,但我被难倒了。你能看看我有没有遗漏什么吗 对象之间的关系是:MarineForm有MarineFormSections,后者有MarineFormFields 存储及其数据属性: Ext.define('MAP.store.MarineFormStore', { e

Extjs4存储类的data属性描述了对象层次结构。我把它作为我的存储的数据属性,因为数据是静态的;无需额外调用服务器来填充存储。我以前也这样做过,但这次我的hasMany关系没有得到改善。我已经尝试了各种方法来解决这个问题,但我被难倒了。你能看看我有没有遗漏什么吗

对象之间的关系是:
MarineForm有MarineFormSections,后者有MarineFormFields

存储及其数据属性

Ext.define('MAP.store.MarineFormStore', {
    extend: 'Ext.data.Store',
    model: 'MAP.model.MarineForm',
    data:[
        {
            species:'Mackerel',
            gear:null,
            sections:[
                {
                    name:'General Info',
                    formFields:[
                        {
                            xtype:'textfield',
                            name:'firstField',
                            allowBlank:false,
                            fieldLabel:'First Field'
                        }
                    ]
                }
            ]
        }
    ]

});
Ext.define('MAP.model.MarineForm', {
    extend: 'Ext.data.Model',

    fields: [
        {name: 'species', type: 'string'},
        {name: 'gear', type: 'string'}
    ],

    hasMany: {
        model: 'MAP.model.MarineFormSection',
        name: 'sections'
    }

});
Ext.define('MAP.model.MarineFormSection', {
    extend: 'Ext.data.Model',

    fields: [
        'id',
        {name: 'name', type: 'string'}
    ],

    hasMany: {
        model: 'MAP.model.MarineFormField',
        name: 'formFields'
    }

});
根模型

Ext.define('MAP.store.MarineFormStore', {
    extend: 'Ext.data.Store',
    model: 'MAP.model.MarineForm',
    data:[
        {
            species:'Mackerel',
            gear:null,
            sections:[
                {
                    name:'General Info',
                    formFields:[
                        {
                            xtype:'textfield',
                            name:'firstField',
                            allowBlank:false,
                            fieldLabel:'First Field'
                        }
                    ]
                }
            ]
        }
    ]

});
Ext.define('MAP.model.MarineForm', {
    extend: 'Ext.data.Model',

    fields: [
        {name: 'species', type: 'string'},
        {name: 'gear', type: 'string'}
    ],

    hasMany: {
        model: 'MAP.model.MarineFormSection',
        name: 'sections'
    }

});
Ext.define('MAP.model.MarineFormSection', {
    extend: 'Ext.data.Model',

    fields: [
        'id',
        {name: 'name', type: 'string'}
    ],

    hasMany: {
        model: 'MAP.model.MarineFormField',
        name: 'formFields'
    }

});
有很多类

Ext.define('MAP.store.MarineFormStore', {
    extend: 'Ext.data.Store',
    model: 'MAP.model.MarineForm',
    data:[
        {
            species:'Mackerel',
            gear:null,
            sections:[
                {
                    name:'General Info',
                    formFields:[
                        {
                            xtype:'textfield',
                            name:'firstField',
                            allowBlank:false,
                            fieldLabel:'First Field'
                        }
                    ]
                }
            ]
        }
    ]

});
Ext.define('MAP.model.MarineForm', {
    extend: 'Ext.data.Model',

    fields: [
        {name: 'species', type: 'string'},
        {name: 'gear', type: 'string'}
    ],

    hasMany: {
        model: 'MAP.model.MarineFormSection',
        name: 'sections'
    }

});
Ext.define('MAP.model.MarineFormSection', {
    extend: 'Ext.data.Model',

    fields: [
        'id',
        {name: 'name', type: 'string'}
    ],

    hasMany: {
        model: 'MAP.model.MarineFormField',
        name: 'formFields'
    }

});
hasMany的hasMany类(第三层嵌套)

以下是在Chrome中查询存储的输出:

rootStore = Ext.getStore('MarineFormStore') // -> the store
sections = rootStore.getAt(0).sections() // -> hasMany store
sections.getCount() // -> 0
我试过:

  • 删除
    MarineFormField有许多
    MarineFormFields的
    block
  • 将id添加到
    MarineFormField
  • 在根存储的
    数据
    字段中三次检查是否有任何输入错误

  • 谢谢你抽出时间

    在我看来,您缺少的只是存储配置中的以下内容(或者您可能只是忘记加载存储):


    包含此更改的代码基本上都是您的代码,而且似乎工作正常。

    就是这样!谢谢你帮我省去了一些痛苦和悲伤。