How to bind Kendo grid to json data using angularjs -
hi using kendo grid bind data json , angularjs here code below. .cshtml page code below.
<div ng-app="sample" ng-controller="samplecontroller"> <div>products: {{products.length}}</div> <div kendo-grid k-data-source="products" k-selectable="'row'" k-pageable='{ "pagesize": 2, "refresh": true, "pagesizes": true }' k-columns='[ { "field": "employeekey", "title": "employeeid"}, { "field": "firstname", "title": "first name"}, { "field": "lastname", "title": "last name"}, { "field": "departmentname", "title": "department name" }, { "field": "emailaddress", "title": "email id" } ]'> </div> </div> <script> var app = angular.module('sample', ['kendo.directives']); app.controller('samplecontroller', function ($scope, $http) { debugger; $http.get('~/api/employee/employee_read').success(function (thisdata) { var mydata = $.parsejson(json.parse(thisdata)); $scope.mydata = mydata; }); $scope.filteroptions = { filtertext: '', useexternalfilter: true, }; }); </script>
and in controller name employeecontroller used json data below:
public actionresult employee_read ([datasourcerequest] datasourcerequest request ) { return json(employeerepositary.employees.todatasourceresult(request), jsonrequestbehavior.allowget); }
this code working fine @htmlkendo grid not able display data. wrong?? please me out here.
use kendo.data.observablearray
case
$http.get('~/api/employee/employee_read').success(function (thisdata) { var mydata = $.parsejson(json.parse(thisdata)); $scope.products= new kendo.data.observablearray(mydata.data); });
Comments
Post a Comment