PDA

View Full Version : Iterating a large JsonStore



mdw233
16 Mar 2011, 8:12 AM
Hi All,

I have a GridPanel (var agentGrid in code) that is bound to a JsonStore (var agentDataStore in code). This store has a field that shows a timer indicating the time a customer service agent is in a state. So, every 15 seconds I fire an event (using setInterval()) that updates the timer on each row by iterating the the JsonStore and updating the appropriate field.

So, here is the event that gets fired every 15 seconds:


function agentTimerTick() {
var newTime = getStateTime(); //assume this always works
agentDataStore.each(function (rec) {
rec.set('statetimedisplay', newTime); //set the field of the JsonStore to the timer value
});
agentDataStore.commitChanges();
}


However, once I get about 120 agents in the JsonStore, the page starts freezing and firefox tells me that my script is taking too long to write.

So, my questions:


Is there a better way to implement a timer in each row of a GridPanel (bound to a JsonStore)? I realize that iterating isn't an efficient process, but how else could I update every row? Keep in mind, I need to show the time in state for each agent.
I would imagine that 200 rows shouldn't bee that many to update, but maybe it is?

rivarecords
16 Mar 2011, 11:29 AM
http://articles.sitepoint.com/article/multi-threading-javascript