I have a method which takes some data from the datasource and via a RESTful webservice, changes it. I then need to update the datasource items.
I am using AngularJS so I have tried updating the $scope variable which is used inside the read method of my datasource ie (in the below example I changed $scope.myLocalResults
read: function (options) {
options.success($scope.myLocalResults);
}
And then called datasource.read() - however this turned out to be quite slow.
I have then tried just updating the changed records - ie my webservice returns an array of records (order guaranteed so I find the originally index of the record from $scope.myLocalResults, and then do:
var dataItem = dataSource.at(index);
dataSource.remove(dataItem);
dataSource.insert(index, myNewRecord);
However this is also quite slow - around 1 second per record, and I have around 2000 records.
Is there a quicker way to achieve what I want to do? I cannot simply using the .set method of the dataItem, as we have around 200 columns which could change.
Also - does .remove and .insert on the dataItem cause any datasource method to be fired, ie read or sync or something like that? I'm trying to work out why this is so slow, in comparison to other operations I am doing to the JS objects.
Thanks
Marc