Ext.getStore()创建错误:未捕获的TypeError:未定义不是函数 [英] Ext.getStore() creating error: Uncaught TypeError: undefined is not a function

查看:184
本文介绍了Ext.getStore()创建错误:未捕获的TypeError:未定义不是函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个 ListView ,并使用我创建的商店中的一些数据填充它.

I am creating a ListView and populating it with some data from a store that I have created.

当我使用以下方式将商店分配给listview时 store : Ext.getStore('Feeds'),出现错误:

When I am assigning the store to the listview using store : Ext.getStore('Feeds'), I get an error :

未捕获的TypeError:未定义不是函数

Uncaught TypeError: undefined is not a function

查看课程:

Ext.define('Volt.view.FeedView', {
    extend: 'Ext.Panel',

    requires: [
        'Ext.TitleBar',
        'Ext.Button',
        'Ext.Toolbar'
        //'Ext.Panel'
    ],

    xtype: 'feedViewCard',

    config: {
        iconCls: 'action',
        title: 'FeedView',
        layout: {
            type: 'vbox'
        },
        items: [
            {
                xtype: 'feedlistview', // this is defined as a class that inherits from xtype = list
                store: Ext.getStore('Feeds'), //removing this line gives no error
                flex: 1,
                    }
                }
            }
        ]
    },
});

商店课程

Ext.define("Volt.store.Feeds", {
    extend: "Ext.data.Store",
    requires: "Ext.data.proxy.LocalStorage",
    config: {
        model: "Volt.model.Feed",
        data: [
            { title: "Feed 1", narrative: "narrative 1" },
            { title: "Note 2", narrative: "narrative 2" },
            { title: "Note 3", narrative: "narrative 3" },
            { title: "Note 4", narrative: "narrative 4" },
            { title: "Note 5", narrative: "narrative 5" },
            { title: "Note 6", narrative: "narrative 6" }
        ],
        sorters:[
            {
                property: 'dateCreated',
                direction: 'DESC'
            }
        ]
    }
});

模型类

Ext.define("Volt.model.Feed", {
    extend: "Ext.data.Model",
    config: {
        idProperty: 'id',
        fields: [
            { name: 'id', type: 'int' },
            { name: 'dateCreated', type: 'date', dateFormat: 'c' },
            { name: 'title', type: 'string' },
            { name: 'narrative', type: 'string' }
        ],
        validations: [
            { type: 'presence', field: 'id'},
            { type: 'presence', field: 'dateCreated'},
            { type: 'presence', field: 'title', 'message': 'Enter a valid title'}
        ]
    }
});

推荐答案

您正在尝试在定义尚不存在的时间内获取商店.如果Feeds存储在应用程序或控制器的stores:[]中列出,则只需将其设置为文本store:'Feeds'.

You are trying to get the store during definition time when it does not yet exist. If Feeds store is listed in stores:[] of the Application or a Controller then just set it to text store:'Feeds'.

应用初始化时,它检测到商店是一个字符串,并为您调用Ext.getStore.

When app initializes it detects that store is a string and calls Ext.getStore for you.

您可能还对 Ext组件生命周期和/或外部应用程序启动顺序

这篇关于Ext.getStore()创建错误:未捕获的TypeError:未定义不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆