This is a migrated thread and some comments may be shown as answers.

Replacing an item in the datasource

1 Answer 210 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Marc
Top achievements
Rank 1
Marc asked on 27 Apr 2017, 08:05 AM

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

1 Answer, 1 is accepted

Sort by
0
Veselin Tsvetanov
Telerik team
answered on 01 May 2017, 08:00 AM
Hello Marc,

In case you have configured the DataSource with remote endpoints, the read(), remove() and insert() methods would always call the remote endpoints, unless you configure the DataSource to perform batch modifications. This means, that you need to set the batch configuration filed of the DataSource to true. This way, the modifications would be sent with a single call to the server, after calling the sync() method of the data source.

If the above suggestion does not improve the performance of the Kendo DataSource, or if you have already configured your DS to be in batch edit mode, we will need a runnable sample to reproduce and troubleshoot this issue. Therefore, I would like to ask you to prepare and send us a Dojo sample, or an isolated sample project, where we could locally observe the reported.

Regards,
Veselin Tsvetanov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Data Source
Asked by
Marc
Top achievements
Rank 1
Answers by
Veselin Tsvetanov
Telerik team
Share this question
or