PDA

View Full Version : JsonStore local update



jimmy3Z
27 Jan 2010, 6:00 AM
Hello,
can somebody please help me with following problem: I have JsonStore (named taskStore) and FormPanel. I need on FormPanel "save" action add a record in JsonStore locally on a client (not submit on server), which is not a problem. But I also need to upgrade certain part of records saved in JsonStore - letīs say increment one item from each record.

I tryied to do it by this way:



var i;
for (i=0; i<taskStore.getCount(); i++) {
if (taskStore.getAt(i).get('order_id') >= 5) { //5 is made up constant
taskStore.getAt(i).get('order_id') += 1;
}
}
which obviously didnīt work, because records are ReadOnly.
Is there any way to do it?

Thanks for answer

maho2nd
27 Jan 2010, 6:18 AM
var i;
for (i=0; i<taskStore.getCount(); i++) {
if (taskStore.getAt(i).get('order_id') >= 5) { //5 is made up constant
taskStore.getAt(i).set('order_id', taskStore.getAt(i).get('order_id') +1);
}
}


or better:


var i;

for (i=0; i<taskStore.getCount(); i++) {
var orderId = taskStore.getAt(i).get('order_id');
if (orderId >= 5) { //5 is made up constant
taskStore.getAt(i).set('order_id', orderId +1);
}
}

jimmy3Z
27 Jan 2010, 7:04 AM
Thanks

Mike Robinson
27 Jan 2010, 7:47 AM
You also might need to somehow use two stores.

But quite frankly, I would suggest ... figure out another approach to your problem. If you find that "your movie is beginning to depend too-much on special effects shots," then you are probably far removed from the well-worn path and there might be alligators nearby.