Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ExtJs Store.Load() vs Model.Load()

What is the difference between store.load() vs model.load()? One uses callback, the other uses success/failure, with slightly different function signatures.

Other than that, is there any main difference to use store.load(), OR not use it and just directly call model.load()? Difference when loading nested models with relationships?

like image 900
Tom Avatar asked Apr 30 '13 07:04

Tom


1 Answers

If you look at "Usage in Stores" section of Ext.data.Model documentation you'll find these two sentences:

A Store is just a collection of Model instances - usually loaded from a server somewhere. Store can also maintain a set of added, updated and removed Model instances to be synchronized with the server via the Proxy.

and

It is very common to want to load a set of Model instances to be displayed and manipulated in the UI

So this means that store is typically used as a collection (or I would call it a repository) of many model instances that syncs data with defined backhand and maintains a list of model instances that can be filtered, queried etc.

On the other hand Ext.data.Model.load method only loads one instance data by specific model id.

Based on this I would say that difference between Ext.data.Model.load and Ext.data.Store.load is in amount of data you want to load (one or many model instances).

like image 125
sbgoran Avatar answered Oct 28 '22 19:10

sbgoran