Search code examples
extjsmodelstorereloadextjs3

Reloading an Ext.data.Store model?


I'm trying to fix some issue with an ExtJs website but not sure how to proceed. Basically, I have a form that loads an Ext.data.Store model. For new models, the model object initially doesn't have an ID. Once it's saved an ID is assigned to it by the webservice.

The problem is that this Ext.data.Store model is not being reloaded after saving, so it stays without an ID, which causes some problems later on.

So is there any way to force ExtJs to reload the store model after saving? I checked the documentation of Ext.data.Store but cannot see any "reload()" or "refresh()" method. Any suggestion?


Solution

  • You don't need to do anything special. ExtJs has a logic to replace models with phantom flag with the new copies received from the store after update procedure. Chec couple things:

    Make sure you have correctly specified idProperty in the model. This is how ExtJs will detect whether record is new or not.

    Make sure your store returns properly new/updated records in the response message.

    Make sure your data reader properly parses these records in the response message.