PDA

View Full Version : Grid not refreshing properly



Madhu11
20 Sep 2011, 6:58 AM
I have two stores associated with a grid.

When grid loads for the first time I display Store1 data into the grid. On selection of certain option in the combo box (which is in a toolbar), Store1 data is copied to Store2 and Store2 is made active store for the grid.

Now I make some changes to values of 2 fields in Store2 using record.set('field', 'newvalue'). One of these field (say Field1) is displayed directly as column in the grid. The other field (Field2) is displayed on mouseover event of Field1. Field2 displays updated value but Field1 displays old value. How do I make the Field1 reflect the updated value in Store2.

Thanks for any help!

Madhu11
20 Sep 2011, 7:22 AM
Hope this snippet helps to understand the problem explained above



// copying 'store1' data to 'store2'
var records = [];
store.each(function(r){
records.push(r.copy());
});

var store2 = new Ext.data.Store({
recordType: store1.recordType
});
store2.add(records);

// associating 'store2' with the grid
Ext.getCmp('grid_id').store = store2;

// changing values in 'store2'
var record = Ext.getCmp('grid_id').store.getAt(1);
record.set('field1', newvalue);
record.set('field2', newvalue);

// new value set field2 is displayed in the grid
// new value set field1 is NOT displayed in the grid
// old value of field1 is displayed

// i tried the following - these statements did not help
store2.reload();
Ext.getCmp('grid_id').getView().refresh();