What is the main difference between JsonStore and JsonReader in the context of Ext.data?

What is the main difference between JsonStore and JsonReader in the context of Ext.data?

I mean, when should I go to JsonStore and when will I use JsonReader, since both provide the same solution for me.

+4
source share
2 answers

These are actually two different things. A Ext.data.JsonReader reads the given JSON object and returns data records ( Ext.data.Record ), which are then stored by the corresponding data store.

Ext.data.Store is the base class for all Ext storages and uses auxiliary objects for data extraction ( Ext.data.DataProxy ) for writing data ( Ext.data.DataWriter ) and for reading data ( Ext.data.DataReader ). These base classes have different tastes, such as:

All this creates up to a very extensible component that allows the developer to fine-tune what he needs to configure. To simplify the work of developers (especially new ones), Ext comes with some pre-configured data warehouses:

So in fact Ext.data.JsonStore is just a convenience class to make it easier for the developer.

The following two fragments 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'}] }); }); 
+17
source

A JsonReader reads JSON from a data source in the Ext Store. JsonData is not a specially defined Ext object, although perhaps you saw it as a variable name? In what context do you use it?

+1
source

Source: https://habr.com/ru/post/1299295/


All Articles