JsonStore和JsonReader在Ext.data的上下文中有什么区别? [英] what's basic difference between JsonStore and JsonReader in context to Ext.data?
问题描述
其实它们是两个不同的东西。 Ext.data.JsonReader
读取给定的JSON对象并返回数据记录( Ext.data.Record
对象),稍后由相应的数据存储。
Ext.data .Store
是所有Ext存储库的基类,并使用帮助对象检索数据( Ext.data.DataProxy
),用于写入数据( Ext.data.DataWriter
)和阅读数据( Ext .data.DataReader
)。这些基类有不同的风格,例如:
这一切都构建了一个非常可扩展的组件,允许开发人员准确地调整他需要调整的内容。为了使开发人员更容易(特别是新的)Ext提供了一些预先配置的数据存储:
-
Ext.data.ArrayStore
使简单的Javascript数组更容易阅读 -
Ext.data.DirectStore
,只是预先配置了一个Ext.data.DirectProxy
和Ext.data.JsonReader
-
Ext.data.JsonStore
,只是预先配置了一个Ext.data.JsonReader
-
Ext.data.XmlStore
,只是一个预先配置了Ext的商店。 data.XmlReader
所以实际上一个 Ext.data.JsonStore
只是一个便利的课程,使开发人员更容易。
以下两个片段将创建相同(或可比较)的商店:
var store = new Ext.data.JsonStore({
url:'get-images.php',
root:'images',
idProperty:'name',
fields:['name','url',{name:'size',type:'float'},{name:'lastmod',type:'date' }]
});
//或
var store = new Ext.data.Store({
url:'get-images.php',
reader:新的Ext.data.JsonReader({
root:'images',
idProperty:'name',
fields:['name','url',{name:'size'键入:'float'},{name:'lastmod',type:'date'}]
});
});
What's basic difference between JsonStore and JsonReader in context to Ext.data?
I mean when I should go for JsonStore and when I should use JsonReader as for me both are providing same solution.
Actually they are two separate things. A Ext.data.JsonReader
reads a given JSON object and returns data records (Ext.data.Record
objects) that are later stored by the respective data store.
The Ext.data.Store
is the base class for all Ext storages and uses helper objects for retrieving data (Ext.data.DataProxy
), for writing data (Ext.data.DataWriter
) and for reading data (Ext.data.DataReader
). These base classes come in different flavors such as:
This all builds up to a very extendable component that allows the developer to configure exactly what he needs to tweak. To make it easier for developers (especially new ones) Ext comes with some pre-configured data stores:
Ext.data.ArrayStore
to make reading from simple Javascript arrays easierExt.data.DirectStore
, just a store preconfigured with anExt.data.DirectProxy
and anExt.data.JsonReader
Ext.data.JsonStore
, just a store preconfigured with anExt.data.JsonReader
Ext.data.XmlStore
, just a store preconfigured with anExt.data.XmlReader
So actually a Ext.data.JsonStore
is just a convenience class to make it easier for the developer.
The following two snippets will create the same (or comparable) stores:
var store = new Ext.data.JsonStore({
url: 'get-images.php',
root: 'images',
idProperty: 'name',
fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
});
// or
var store = new Ext.data.Store({
url: 'get-images.php',
reader: new Ext.data.JsonReader({
root: 'images',
idProperty: 'name',
fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
});
});
这篇关于JsonStore和JsonReader在Ext.data的上下文中有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!