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

How to use Angular-Resource service with TreeList DataSource?

2 Answers 67 Views
Integration with other JS libraries
This is a migrated thread and some comments may be shown as answers.
f
Top achievements
Rank 1
f asked on 23 Jul 2015, 08:26 PM

I m trying to integrate Kendo-ui into my AngularJS app. I have a working AngularJS app with ngResource as following:

(function () {
"use strict";
angular
.module("app")
.controller("RoleListCtrl",
["roleResource",
RoleListCtrl]);
function RoleListCtrl(roleResource) {
var vm = this;
roleResource.query(function (data) {
vm.roles = data;
});
}
}());

I want to use the same roleResource.query() to get data for a <kendo-treelist options="treelistOptions"></kendo-treelist>. I tried as following:

$scope.treelistOptions = {
dataSource: {
type: "odata",
transport: {
read: function (e) {
roleResource.query(function (data) {
return data;
});
}
},
schema: {
model: {
id: "id",
expanded: true
}
}
}, ......

It can start to loading data but the data never loaded (the loading.gif running for ever).

What is the right way to use Angualr-Resource with kendo dataSource?

Thanks,

2 Answers, 1 is accepted

Sort by
0
f
Top achievements
Rank 1
answered on 23 Jul 2015, 10:32 PM

Edit...

I just modified my code as kendo document:

dataSource: {
transport: {
read: {
dataType: "jsonp",
data: {
q: function () {
var roles;
roleResource.query(function (data) {
roles = data;
});
return roles;
}
}
}
}
},

It still does not work. I got a "Request failed" message with a "Retry" button on screen. I can see the data successfully downloaded with correct json format by browser's developing tool, but these data can't show on screen.

I tried to copy the downloaded data to local data and use it in the dataSource. It works fine.

Please advise!

0
Nikolay Rusev
Telerik team
answered on 27 Jul 2015, 04:05 PM

Hello,

 

There is an example of how to Bind the Grid using the $http service. You can use the same approach for the TreeList as well.

 

Regards,
Nikolay Rusev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Integration with other JS libraries
Asked by
f
Top achievements
Rank 1
Answers by
f
Top achievements
Rank 1
Nikolay Rusev
Telerik team
Share this question
or