Search code examples
extjsmodelgridstoreextjs5

Update model of a grid store on the fly


A grid is configured with a store that use a model that I can call modelA

I need to change on the fly the model of the store related to the grid. I followed following approach without results:

grid.getStore().setModel(modelB);

grid.reconfigure(
    grid.getStore(),
    columns
);

grid.getStore().load();

It continues to use the model defined at the beginning. In fact if I debug the record that is passed to the renderer function as follows:

function(value, metadata, record)...

record continues to reference modelA instead of modelB.

How can I change dynamically the model of the store?


Solution

  • I think that although you set new model you haven't re-read the records, at least you do not show any store.load() call. Models are used by store/proxy/reader to create instances when the store is loaded.

    Now, I wouldn't use this approach anyway. Store is not a very expensive in terms of performance or memory so if I'd need to reconfigure the grid I'd use another store with that another model.