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

[Solved] Grid datasource odata problem with angularjs.

1 Answer 174 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Antti
Top achievements
Rank 1
Antti asked on 30 Jun 2016, 12:20 PM

Hello,

I have a problem with reading oData to grid datasource with angularjs.
I have the following test method:

01.$scope.search = function (searchCriteria) {
02.     var users = new kendo.data.DataSource({
03.         dataType:"odata",
04.         transport: {
05.             read: {
06.                 async: true,
07.                 url: "http://services.odata.org/V4/Northwind/Northwind.svc/Customers"
08.             },
09.             schema: {
10.                 data: "value",
11.                 total: "odata.count"
12.             },
13.             serverPaging: true,
14.             serverSorting: true,
15.             serverFiltering: true,
16.             pageSize: 5
17. 
18.         },
19.         sortable: true,
20.         pageable: true,
21. 
22.     });
23. 
24. 
25. 
26. 
27.     users.read().then(function success() {
28.         $scope.userGridOptions.dataSource.data(users.data());
29.         $scope.grid.refresh();
30.     },
31.     function error(error) {
32.         $log.error(error);
33.     });
34. 
35.     $scope.userGridOptions.pageable = true;
36.     $scope.userGridOptions.pageSize = 5;
37.     $scope.userGridOptions.scrollable = {
38.         virtual: true
39.     };
40. 
41. 
42. };

On click from view the method is called. I have an existing datasource available and I want to refresh it.
The data is retrieved nicely (see the attachment), but in the code on line 27

users.read().then(function success() {

I get an error "TypeError: e.slice is not a function".

Could you please help me out. What am I doing wrong?

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 04 Jul 2016, 09:29 AM
Hi Antti,

The correct configurations should look like this:

var users = new kendo.data.DataSource({
  type:"odata",

You may find a working example here.

Regards,
Alexander Valchev
Telerik
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
Tags
Grid
Asked by
Antti
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or