I was working on a Code-Library Project.
This is a sample ASP.NET Web API test application.
I do see the success callback function being called, and "data" does seem to carry the expected json object array.
TestContract.cs & TestContoller.cs
app.js ( AngularJS module definition )
TestService.js AngularJS Service
TestController.js AngularJS Controller
Index.cshtml
Attachments :
1) Error.PNG
shows the error I am getting in browser's Dev Tools console after sucess call back
2) transport service success callback has expected data.PNG
showing the data-tip in Visual Studio with expected data.
If you'd like to investigate, I have a test application ready.
Please let me know if I have to remove something prior to upload.
I am not using any telerik's dlls but I do am using references to Kendo UI CDN libraries.
This is a sample ASP.NET Web API test application.
I do see the success callback function being called, and "data" does seem to carry the expected json object array.
TestContract.cs & TestContoller.cs
public
class
TestContract
{
public
int
Id {
get
;
set
; }
public
string
Name {
get
;
set
; }
public
string
Description {
get
;
set
; }
}
public
class
TestController : ApiController
{
private
IEnumerable<TestContract> getTestData()
{
return
(
new
TestContract[] {
new
TestContract{ Id = 1, Name =
"Name 1"
, Description =
"Description 1"
},
new
TestContract{ Id = 2, Name =
"Name 2"
, Description =
"Description 2"
},
new
TestContract{ Id = 3, Name =
"Name 3"
, Description =
"Description 3"
},
new
TestContract{ Id = 4, Name =
"Name 4"
, Description =
"Description 4"
},
new
TestContract{ Id = 5, Name =
"Name 5"
, Description =
"Description 5"
}
}).AsEnumerable();
}
...
app.js ( AngularJS module definition )
var
app = angular.module(
'app'
, [
'kendo.directives'
]);
app.filter(
"asDate"
,
function
() {
return
function
(input) {
return
new
Date(input);
}
});
TestService.js AngularJS Service
(
function
() {
'use strict'
;
angular
.module(
'app'
)
.service(
'TestService'
, ['$http', TestService]);
function
TestService($http) {
this
.getData = getData;
function
getData() {
return
$http.get(rootUrl +
'api/test'
);
}
}
})();
TestController.js AngularJS Controller
(
function
() {
'use strict'
;
angular
.module(
'app'
)
.controller(
'TestController'
, [
'$scope'
,
'TestService'
,
'$http'
, TestController]);
function
TestController($scope, service, $http) {
$scope.title =
'TestController'
;
$scope.testGridOptions = {
columns: [
{ field:
"Id"
, title:
"Column 1"
},
{ field:
"Name"
, title:
"Column 2"
},
{ field:
"Description"
, title:
"Column 2"
}
],
dataSource: {
schema: {
data:
"d"
},
transport: {
read:
function
(e) {
service.getData().
success(
function
(data, status, headers, config) {
e.success(data)
}).
error(
function
(data, status, headers, config) {
alert(
'something went wrong in test grid'
)
console.log(status);
});
}
},
pageSize: 5
}
};
}
})();
Index.cshtml
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<
h2
>Index</
h2
>
<
div
data-ng-controller
=
"TestController"
>
<
div
>Controller: {{title}}</
div
>
<
div
>Grid 2 Starts</
div
>
<
div
data-kendo-grid
=
""
data-k-options
=
"testGridOptions"
></
div
>
<
div
>Grid 2 Ends</
div
>
</
div
>
Attachments :
1) Error.PNG
shows the error I am getting in browser's Dev Tools console after sucess call back
2) transport service success callback has expected data.PNG
showing the data-tip in Visual Studio with expected data.
If you'd like to investigate, I have a test application ready.
Please let me know if I have to remove something prior to upload.
I am not using any telerik's dlls but I do am using references to Kendo UI CDN libraries.