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

How binding AngularJS & Kendo with $http Service.

8 Answers 536 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Oren
Top achievements
Rank 1
Oren asked on 12 Aug 2014, 08:39 AM
Hi,
We have a angularJS project and we work also with Kendo UI (Grid)
We want to bind the Grid dataSource with $http Service.
All the official examples of AngularJS & Kendo are binding to local dataSource or WCF(.svc) links:
http://demos.telerik.com/kendo-ui/grid/angular (attached src1) 

Can you show me or send a reference for best practice way to bind kendo with $http Service.  

thanks in advance. 

8 Answers, 1 is accepted

Sort by
0
Lars
Top achievements
Rank 1
answered on 26 Aug 2014, 03:48 PM
In case you still need this, here is one example that I got from Telerik support for a similar question:
http://dojo.telerik.com/@pesho/EyOn


0
Petur Subev
Telerik team
answered on 27 Aug 2014, 11:13 AM
Hello Guys,

I added this as a small example into the documentation regarding the Grid when used with Angular:

http://docs.telerik.com/kendo-ui/getting-started/using-kendo-with/AngularJS/the-grid-widget#how-to-bind-the-grid-using-the-http-service

Regards,
Petur Subev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Aarsh
Top achievements
Rank 1
answered on 21 Jan 2015, 07:17 PM

I've another issue using Professional Kendo UI, binding Grid with AngularJS $http service

I've modified the demo and shared here :

http://dojo.telerik.com/EHUzu

1)    If I change a demo project I at-least see a network activity for http://filltext.com
2)    But I do NOT see a grid on page !


if I try the code below

01.$scope.getMessageQueueKendo = function () {
02.    var v = 'test';
03.    $scope.gridOptions = {
04.        columns: [
05.            { field: "Id" },
06.            { field: "Data_Contract_Field_1" },
07.            { field: "Data_Contract_Field_2" },
08.            { field: "Data_Contract_Field_3" },
09.            { field: "Data_Contract_Field_4" },
10.            { field: "Data_Contract_Field_5" }
11.        ],
12.        dataSource: {
13.            schema: {
14.                data: "d"
15.            },
16. 
17.            transport: {
18.                read: function (e) {
19.                    service.getData(0, -1).success(function (data, status, headers, config) {
20.                        e.success(data);
21.                    }).
22.                    error(function (data, status, headers, config) {
23.                        alert('error');
24.                        console.log('Error getting message queue. Server returned status : ', status);
25.                        console.log(data);
26.                    });
27.                }
28.            }
29.        },
30.        pageSize: 5
31.    }
32.};

 

0
Aarsh
Top achievements
Rank 1
answered on 21 Jan 2015, 07:20 PM
... if I try the code snippet above for my actual project, which is asp.net web api project running on .NET 4.5.2, the controller is not getting hit, nor I see any activity for that URL in fiddler or dev toools.

Nor, I see the grid view at all !

Any idea what's happening ?
0
Aarsh
Top achievements
Rank 1
answered on 21 Jan 2015, 07:29 PM
Let me also mention that the example is from http://docs.telerik.com/kendo-ui/AngularJS/the-grid-widget#how-to-bind-the-grid-using-the-http-service

Also, the AngularJS service function call I've mentioned in the code snippet above, has the following definition.

function getData() {
    return $http({
        url: baseUrl + 'Get',
        method: 'GET'
    });
}
0
Kiril Nikolov
Telerik team
answered on 23 Jan 2015, 01:25 PM

Hello Aarsh,

 

In your example the schema.data option is not needed, since you return the data in an array, without an object with a "d" key. Here is the working example:

 

http://dojo.telerik.com/@Kiril/iPiSO

 

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
AFIS Team
Top achievements
Rank 1
answered on 24 Jan 2017, 03:31 PM

Hi,

I'm trying to do the same as in the examples you posted, but also for the create method of the datasource transport object.

So, in my create method, I use the angular $http library and in the corresponding success and error callbacks, I do options.success() and options.error() respectively (where options is the argument to the create method).

However, what I notice is that when I have an error returned from the $http call, which triggers the error callback, an empty grid line is added to the grid anyway, and subsequent clicks on the button to re-send the data seem to trigger more AJAX calls (one more for each click, so on the 5th click it will trigger 5 failed AJAX calls).

What could I be doing wrong?

My create method looks something like this:

create: function(options) {
  return $http({
    url: myUrl,
    method: 'POST',
    data: myData
  })
  .success(function(response) {
    options.success();
  })
  .error(function(response) {
     options.error();
  })
}
0
Kiril Nikolov
Telerik team
answered on 25 Jan 2017, 08:16 AM
Hello,

Would it be possible to open a separate ticket and send us a runnable sample where the issue can be reproduced, and we will be happy to help.

Regards,
Kiril Nikolov
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
Grid
Asked by
Oren
Top achievements
Rank 1
Answers by
Lars
Top achievements
Rank 1
Petur Subev
Telerik team
Aarsh
Top achievements
Rank 1
Kiril Nikolov
Telerik team
AFIS Team
Top achievements
Rank 1
Share this question
or