Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

in ExtJS, is it better to call Model.save() or Store.Sync()?

Tags:

extjs

And what are the ramifications of each?

I see that Model.save(), for example, automatically refreshes the Model with results from the server. I'm not sure if sync() does.

like image 948
Paul Avatar asked Apr 11 '12 22:04

Paul


1 Answers

automatically refreshes the Model with results from the server

Store.sync() refreshes modified records as well (provided you have setup the server response correctly).

So, technically, both methods do the same. However, in my opinion, you can use Model.save() only in one case: when you don't have store. Why? Because when you have store and nevertheless you use Model.save() that's mean that you have setup connection (proxy) configuration for both store and model. And that's mean that you have duplicated code which is potentially harder to maintain.

So, to summarize, you use Model.save() only if you use standalone model, without store (it may be the case when you have form which is not connected to any grid. So you create standalone model for such form), and you use Store.sync() in other cases.

like image 152
Molecular Man Avatar answered Nov 11 '22 06:11

Molecular Man