View Full Version : Refresh models without reloading the store?

16 Mar 2012, 4:38 AM

I have the following situation. A grid and a store with a model.

The model contains some convert methods like this (simplified):

fields : [
name : 'Status',
type : 'string',
convert : function(value, record) {
return (value == GlobalStatus)'Global':'NonGlobal';

The store normally loads its content per ajax. At this time, the Status is converted.

Now the GlobalStatus changes. If I call store.load(). The ajax request is done, the grid looses its scroll progress and the new value is shown.
Is there a possibility to do this without a new unnecessary ajax-request and the loss of the scroll progress?

I already tried: store.fireEvent('refresh',store)


16 Mar 2012, 5:17 AM
i didn't really understand your problem, but if you want to refresh only a row in the grid
by loading that model you can do this :

model = grid.getSelectionModel().getSelection()[0];

P.S. you must define the proxy in the model..

20 Mar 2012, 3:01 AM
Load does not work on model instances. It only works on the model itself. You have to do MyApp.Model.load(id);.
So your example have to look like this:

model = grid.getSelectionModel().getSelection()[0];

But this will also fire a new Request and that is what I do not want. The Request also contains the record id and unfortunately our server does not support this.

I only need something to re-run the convert methods of the fields.

Best Regards

20 Mar 2012, 6:22 AM
Let have a try with

var record = grid.getSelectionModel().getSelection()[0];
var fields = record.fields.items;
var length = fields.length;
var rawData = record.raw;
var isArray = Ext.isArray(rawData);
var newData = {};

for (var i = 0; i < length; i++) {
var field = fields[i];
var name = field.name;

if (isArray){
newData[name] = rawData[i];
} else {
newData[name] = rawData[name] !== undefined ? rawData[name] : field.defaultValue ;


26 Mar 2012, 7:11 AM
It is very simple.

I only have to set the values I want to reconvert to a new value.

For me it is record.set('foo','');, as foo does not depend on its own value. Normally you should set the new value here.

Regards farion