PDA

View Full Version : Grid: set column value very SLOW



Dafram
26 May 2014, 11:44 PM
Hi!

I have a program with a grid. In this grid I can set all the values of a column with a single action.

I do like this:



var g = Ext.getCmp('id_myGrid');
var s = g.getStore();
var tot = s.getCount();
tot--;
var records = s.getRange(0,tot);


Ext.each(records, function(record) {
record.set("col_01",val);
});


It works, but is VERY SLOW!!! (in a grid with 40 rows, the execution time is more than 60 seconds!)

So I think I'm doing something wrong...

Can you help me, please?

Thanks in advance.

scottmartin
27 May 2014, 6:06 AM
Using *.each() is very slow. Use a for/loop instead.

Also use batching



record.beginEdit();

record.set('first', 'First');
record.set('last', 'Last');

record.endEdit();

// or push them at once
record.set({
first: 'First',
last: 'Last'
});


Also have a look at:


// suspend store events
store.suspendEvents();
store.resumeEvents();

// suspend component layout
Ext.suspendLayouts();
Ext.resumeLayouts(true);