Datastore

I’me using dhtmlxScheduler an dhtmlxgrid with a datastore.
It is working very good, but I’ve problems with removing some records.
In following function there where deleted 2 records.

function urentotaal(){
var rowsCount = data2.dataCount();
for (var rInd = 0;rInd < rowsCount;rInd++) {
if (data2.item(data2.idByIndex(rInd)).type.toString()==‘AT’){
alert(data2.idByIndex(rInd));
data2.remove(data2.idByIndex(rInd));
}
}
plangrid.sync(data2);
}
records: b0000 and b2000 are deleted

If I remove “data2.remove(data2.idByIndex(rInd));” It shows 4 records.
records: b0000; b1000; b2000 and b3000 are shown

Maybe someone is having an idea?

regards,

Laurens

Please, provide with a more detailed sample of your code with the init of you datastore, dataprocessor, grid.

Hello,

In attached file is the code.
When started Push button Alert, you see 4 items.
With button Remove you see 2 items.

The function which is called us urentotaal on rule 476

Thanx for looking for the problem.

Regards.
demo.zip (16.1 KB)

Please, try to add the following:

function urentotaal(i){ var rowsCount = data2.dataCount(); for (var rInd = 0;rInd < rowsCount;rInd++) { if (data2.item(data2.idByIndex(rInd)).type.toString()=='AT'){ alert(data2.idByIndex(rInd)); if(i){ data2.remove(data2.idByIndex(rInd)); rInd--; // avoid jumping through one of the record } } } }

Thanx,
it works!!
:smiley: :smiley:
regards