<div ng-controller="ContactsController as contact"> <div id="Grid" ej-grid e-datasource="contact.Cdata" e-toolbarsettings='contact.tools' e-columns="contact.columns" e-allowsorting="true" e-allowpaging="true" e-editsettings-allowadding="true" e-editsettings-allowediting="true" e-allowreordering="true" e-allowresizing="true"> </div> </div> <script> angular.module('listCtrl', ['ejangular']) .controller('ContactsController', function ($scope, $http, $q) { this.columns = [ { field: "EmployeeID", width: 105, textAlign: ej.TextAlign.Right, headerText: "Employee ID" }, { field: "EmployeeName", headerText: 'Employee Name', width: 100 }, { field: "Country", headerText: 'Country', width: 110 }, { field: "Number", headerText: 'Number', width: 90 }, { field: "Verified", headerText: 'Verified', width: 90 } ] this.tools = { showToolbar: true, toolbarItems: ["add", "edit", "delete", "update", "cancel"] }; ContactsController(this); function ContactsController(CommonService) { CommonService.Cdata = []; var d = $http.get("/api/Values/GetContactsbyClientId?clientId=1", { cache: true }); d.then(function (response) { CommonService.Cdata = response.data.Items; console.log("success"); }, function (error) { console.log("error"); }); } }); |
angular.module('listCtrl', ['ejangular']) .service('CommonService', ['$http', function ($http) { this.getCantactList = function () { return $http.get("/api/Values/GetContactsbyClientId?clientId=1", { cache: true }); } }]) .controller('ContactsController', ["CommonService", function (CommonService) { this.Cdata = []; this.columns = [ { field: "EmployeeID", width: 105, textAlign: ej.TextAlign.Right, headerText: "Employee ID" }, { field: "EmployeeName", headerText: 'Employee Name', width: 100 }, { field: "Country", headerText: 'Country', width: 110 }, { field: "Number", headerText: 'Number', width: 90 }, { field: "Verified", headerText: 'Verified', width: 90 } ]; this.tools = { showToolbar: true, toolbarItems: ["add", "edit", "delete", "update", "cancel"] }; var d = CommonService.getCantactList();
proxy = this;
d.then(function (response) { proxy.Cdata = response.data.Items; console.log("success"); }, function (error) { console.log("error"); }); }]); |
columns: [ . . . .
{ headerText: "Employee Image", template: true, templateID: "#columnTemplate", textAlign: "center", width: 110 },
|
{ headerText: "Employee Details", commands: [ { type: "details", buttonOptions: { htmlAttributes: { id: "CustomButton", class: "btn-primary", style: "height: 28px; width: 100px;" }, text: "Details", click: "onClick" } } ], isUnbound: true, textAlign: ej.TextAlign.Center, width: 150 |
I have make changes according to your suggestions but its not working i.e data not bind to grid.
I getting data, array of rows in response.Items
So, i have assigned like,
proxy.data = response.result;
but its not working and when i checked data by console.log(response.Items) then it is getting in console.log but not binding to grid