user49126
user49126

Reputation: 1863

Ext JS and loading data into a form

I have build a simple MVC application where I have a form and I need to load data into it.

I'm wondering if I should load this data using a store or directly using the model class. I have already a store for my grid.

So I see this 3 option.

  1. Load data using Model class
  2. Load data using the existing store (a grid uses this store already)
  3. Create a second store and load my data using it.

Upvotes: 1

Views: 179

Answers (1)

sra
sra

Reputation: 23983

  • If your store uses the same model and the data (record) you edit will defiantly be loaded in that store (for example if you open the form on a double-click of a gridrow) or can be inserted into it I recommend you to go with the store approach.

  • If you edit a record (model-instance) that will not necessarily loaded into the grid-store the you should load the data using the model.

  • A second store will only be necessary if both points above are true and you also wan't to batch multiple record (model-instance) edits from that form into one request to the server.

  • A third option is to bind the form directly to the server, but I recommend you to use the model-approach.

Note that if you need a different proxy for the store and the model simply set one on the model and one on the store. By default the store will inherit the proxy of the model but never the model the proxy of the store

Upvotes: 1

Related Questions