【问题标题】:ExtJS Error : No Such EntityExtJS 错误:没有这样的实体
【发布时间】:2016-05-27 03:35:20
【问题描述】:

我是 ExtJS 的新手。

我想显示一个编辑表单,它需要一个链接到远程数据存储(类别数据存储)的组合框组件,如下所示:

Ext.define('AccountingApp.view.content.accAccountSubCategory.Form', {
    extend: 'Ext.window.Window',
    xtype: 'accAccountSubCategoryForm',

    requires: [
        'Ext.window.Window',
    ],

    bind: {
        title: '{title}'
    },
    layout: 'fit',
    modal: true,
    width: 500,
    height: 430,
    closable: true,
    constrain: true,

    items: {
        xtype: 'form',
        reference: 'form',
        bodyPadding: 10,
        border: false,
        modelValidation: true,
        layout: {
            type: 'vbox',
            align: 'stretch'
        },
        items: [{
            xtype: 'combobox',
            reference: 'accaccountcategory',
            publishes: 'value',
            fieldLabel: 'Select Category',
            displayField: 'account_category',
            valueField: 'id',
            anchor: '-15',
            store: Ext.create('Ext.data.Store', {
                proxy: {
                    type: 'ajax',
                    url: 'backend/accAccountCategory/combo',
                    reader: {
                        type: 'array',
                        rootProperty: 'data'
                    }
                },
                //the error is here
                model: 'AccountingApp.model.AccAccountCategory',
                autoLoad: true
            }),
            minChars: 0,
            queryParam: 'q',
            queryMode: 'remote',
        }]
    },

    buttons: [{
        text: 'Save',
        handler: 'onSaveClick'
    }, {
        text: 'Cancel',
        handler: 'onCancelClick'
    }]
});

但是,在这一行:

model: 'AccountingApp.model.AccAccountCategory',

我收到了错误信息:

Uncaught Error: No such Entity "AccountingApp.model.AccAccountCategory".

我尝试将模型更改为model: 'AccAccountCategory',,但错误相同。

你能告诉我代码有什么问题吗?

【问题讨论】:

  • 尝试了一些技巧,最后我发现我们可以根据我们的模型定义将model: 'AccountingApp.model.AccAccountCategory',替换为fields: [ 'id', 'account_category' ],。但这个解决方案是暂时的,仍在等待最佳答案:)。
  • 你没有展示最关键的部分。你在哪里声明了模型?

标签: extjs extjs5


【解决方案1】:

您的答案取决于您的程序使用的架构。

首先:你必须需要你的模型。

requires: [
    'Ext.window.Window',
    'AccountingApp.model.AccAccountCategory'
],

第二:在此模式中,您必须使用此代码创建模型,作为商店配置中的项目:

model: Ext.create('AccountingApp.model.AccAccountCategory'),

【讨论】:

  • 一个建议:尝试使用 Sencha cmd 使用 ExtJs MVC 模式构建或生成您的应用程序......如此简单如此强大......
  • 像魅力一样工作。谢谢..是的,我正在使用 Sencha cmd 来构建这个应用程序。
猜你喜欢
  • 1970-01-01
  • 2012-08-19
  • 1970-01-01
  • 2023-03-08
  • 2018-07-14
  • 2018-06-21
  • 2011-07-11
  • 2018-12-14
  • 2014-09-23
相关资源
最近更新 更多