PDA

View Full Version : Callback in loop



chetan.nellekeri
2 Aug 2013, 1:25 AM
I have a list of records.
For each record I need to call the service. I am writing store.each().. Inside this look i am using callback and adding data to the new store. But it is adding same data.

aaugen
2 Aug 2013, 2:06 AM
Hi,

If you want help I suggest you publish more details on your application code.

Alex.

chetan.nellekeri
2 Aug 2013, 3:24 AM
I cannot add business logic here. So just generalized the code and added. Please review.. Highlighted code contains repeated data. Please let me know if further data needed

var myStore= Ext.create ('Ext.data.Store', {
model: //Some model with data
});

var resultStore= Ext.create ('Ext.data.Store', {
model: //Some model with data
});

myStore1.setProxy('myProxy');
myStore.each(function(record){
var1 = record.get('idNumber'));
var2 = 'grpInd';

myStore1.load({
params: {
var1: var1,
var2: var2
},
callback: function(records, operation, success){
if (me.checkStoreCallbackFailure(operation) == false)
{
document = myStore1.first();
resultStore.add(document);
}

}
});
});

chetan.nellekeri
2 Aug 2013, 3:42 AM
Example code.. Just copied for business code...changed variable names


var plcyDocStore = Ext.create ('Ext.data.Store', {
model: //Some model
});

myStore1.setProxy('myProxy');
myStore.each(function(record){
var1 = record.get('idNumber'));
var2 = 'grpInd';

myStore1.load({
params: {
var1: var1,
var2: var2
},
callback: function(records, operation, success){
if (me.checkStoreCallbackFailure(operation) == false)
{
document = myStore1.first();
myStore1.add(document);
}

}
});
});

aaugen
5 Aug 2013, 12:57 AM
Hi,

Inspect under javascript consol your records parameter from callback function to see if returning data are ok considering your 2 params. Your problem is maybe on your constroller...