无法使用 store.getById() 从存储中读取模型记录
Unable to read Model Records from store by using store.getById()
我正在尝试为我的sencha Ext JS应用程序实现i18n。我使用了[https://github.com/elmasse/Ext.i18n.Bundle-touch/blob/master/i18n/Bundle.js][1]中的impl,但使用了更简化的版本。
基本上,我有一个链接到模型[webUi.util.rb.ResourceBundle]的商店[webUi.util.rb.model.KeyValPair],试图将json数据加载到存储中。加载数据后,我正在尝试通过不同的存储函数访问加载的数据。但不明白..?任何人都可以找到我缺少的东西..?
商店类
Ext.define('webUi.util.rb.ResourceBundle', {
extend: 'Ext.data.Store',
requires: [
'webUi.util.rb.model.KeyValPair'
],
constructor: function(config){
config = config || {};
var me = this;
Ext.applyIf(config, {
autoLoad: true,
model: 'webUi.util.rb.model.KeyValPair',
proxy:{
type: 'ajax',
url: webUi.util.AppSingleton.uiRsrcUrl,
noCache: true,
reader: {
type: 'json',
rootProperty: 'bundle'
},
getParams: Ext.emptyFn
},
listeners:{
'load': this.onBundleLoad,
scope: this
}
});
me.callParent([config]);
me.getProxy().on('exception', this.onBundleLoadException, this, {single: true});
},
onBundleLoad: function(store, record, success, op) {
if(success){
this.fireEvent('loaded');
} else{
this.fireEvent('loadError');
}
},
onBundleLoadException: function(){
console.dir(arguments);
},
onReady: function(fn){
this.readyFn = fn;
this.on('loaded', this.readyFn, this);
},
getMsg: function(key){
return this.getById(key)? Ext.util.Format.htmlDecode(this.getById(key).get('val')) : key + '.undefined';
}
});
模型类
Ext.define('webUi.util.rb.model.KeyValPair', {
extend: 'Ext.data.Model',
config: {
idProperty: 'key',
fields: ['key', 'val']
}
});
杰伦响应
{"bundle":[{"key":"one","val":"Oneee"},{"key":"two","val":"Twooo"}]}
我的代码
var bundle = Ext.create('webUi.util.rb.ResourceBundle');
bundle.onReady(function(){
console.log('%%%%%%%%%%%%%');
console.log(bundle.getMsg('one'));
console.log(bundle.getById('one'));
console.log(bundle.getAt(0));
});
控制台.log
%%%%%%%%%%%%%
one.undefined
null
constructor {raw: Object, modified: Object, data: Object, hasListeners: HasListeners, events: Object…}
尝试使用 bundle.data.getMsg()
相关文章:
- 如何将从XML读取的值存储到本地对象's成员使用.get()函数
- 可以't读取本地存储的远程变量的内容
- 如何存储&读取输入字段中的任意url
- Chrome,Safari在从本地存储读取时挂起,而Firefox很好
- 节点证书存储,节点仅从硬编码的证书列表中读取
- 如何从本地文件夹(磁盘存储)读取或获取图像文件,并使用nodejs服务器将其发送到Angularjs
- 如何读取存储在图像的数据src中的URL,并在另一个img控制器的src中设置该URL onclick
- 正在从本地windows存储文件夹读取js中的文件
- 如何读取mysql表记录并存储在javascript对象中
- 无法使用 store.getById() 从存储中读取模型记录
- 是否可以在页面中设置本地存储或会话变量 asp.net 并在另一页面上的javascript中读取它
- 余烬未正确初始化存储:无法读取未定义的属性“查找”
- 在一次读取中加载本地存储
- 读取 Javascript 本地存储以填充自动完成
- 无法使用本地存储读取未定义的属性推送
- 使用js从本地存储读取文件
- 是否有任何方法从存储读取而不是从组件在React-redux
- 我想从Extjs 4的存储读取数据,但它显示[对象对象]
- 从html 5本地硒存储读取
- 从html5本地存储读取JSON