在使用 extjs 4 的商店和模型时,我感到很沮丧。
Store defined with no model. You may have mistyped the model name.
即使我在商店中指定了模型名称,我也会收到错误消息。
这是我的代码:
Ext.define('iWork.store.CandidateDistribution', {
extend: 'Ext.data.TreeStore',
autoLoad: true,
requires: 'iWork.model.Location',
model: 'iWork.model.Location',
proxy: {
type: 'ajax',
url: 'data/CandidateDistribution/CandidateCount.json',
reader: {
type: 'pentahoReader',
root: 'resultset'
}
},
listeners: {
load: function(treeStore, currentNode, records, success, options) {
console.log('in load listener');
console.log(records);
},
beforeappend: function(currentNode, newNode, options) {
console.log('in beforeAppend listener');
},
add: function(store, records, options) {
console.log('in add listener');
},
beforeinsert: function(currentNode, newNode, option) {
console.log('in beforeInsert listener');
}
}
});
我尝试更改model: 'iWork.model.Location',
为model: 'Location'
,model: "Location"
和 tomodel: "iWork.model.Location"
但仍然无法正常工作。
模型文件中的代码如下:
Ext.define('iWork.model.Location', {
extend: 'Ext.data.Model',
fields: [
{name: 'name', type: 'string'},
{name: 'candidateCount', type: 'string'}
]
});
和引用此商店的树形面板代码如下:
Ext.define('iWork.view.CandidateDistribution', {
extend: 'Ext.window.Window',
alias: 'widget.candidateDistribution',
require: ['iWork.store.CandidateDistribution'],
layout: {
type: 'hbox',
align: 'stretch'
},
autoShow: true,
initComponent: function() {
this.items = [
{
xtype: 'treepanel',
title: 'Location wise customer Distribution',
store: 'iWork.store.CandidateDistribution',
width: '25%',
height: '100%',
rootVisible: false
}
];
this.callParent(arguments);
}
});
我试图改变store: 'iWork.store.CandidateDistribution'
,store: 'CandidateDistribution'
但它也不起作用。
如果我更改store: 'iWork.store.CandidateDistribution'
为store: CandidateDistribution
,我会收到以下错误ext-debug.js (line 8002)
me.store is undefined
[Break On This Error] },
我无法找到我在哪里犯了错误。如果我错过了任何其他配置或我做错了什么,请告诉我。
谢谢 !!
编辑 1:我的应用程序的 index.html 文件如下所示:
<html>
<head>
<title>iWork Dashboards</title>
<link rel="stylesheet" type="text/css" href="../extjs/resources/css/ext-all.css" />
<script type="text/javascript" src="../extjs/ext-debug.js"></script>
<script type="text/javascript" src="app/app.js"></script>
<script type="text/javascript" src="app/PentahoReader.js"></script>
</head>
<body>
</body>
</html>