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

前端 未结 1 1279
余生分开走
余生分开走 2021-02-08 00:23

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 sur

1条回答
  •  暖寄归人
    2021-02-08 01:08

    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.

    0 讨论(0)
提交回复
热议问题