{"id":884,"date":"2015-03-28T08:48:41","date_gmt":"2015-03-28T12:48:41","guid":{"rendered":"http:\/\/shirishranjit.com\/blog1\/?page_id=884"},"modified":"2015-03-28T12:43:31","modified_gmt":"2015-03-28T16:43:31","slug":"angularjs-nggrid-example","status":"publish","type":"page","link":"https:\/\/shirishranjit.com\/blog1\/technical-posts\/javascript-world\/angularjs-nggrid-example","title":{"rendered":"AngularJS ngGrid &#8211; example"},"content":{"rendered":"<p>ngGrid is a powerful grid library; however, there is confusion in how it works. Here is an example of ngGrid that works for the following versions:<\/p>\n<ul>\n<li>ngGrid &#8211; 2.x\n<ul>\n<ol>ng-grid-2.0.14.debug.js<\/ol>\n<ol>ng-grid-2.0.14.min.js<\/ol>\n<ol>jquery-1.8.2.js<\/ol>\n<\/ul>\n<\/li>\n<li>AngularJS &#8211; 1.3.14<\/li>\n<\/ul>\n<h2>Step 1<\/h2>\n<p>Make sure that the ng-app and ng-controller for angular is defined in html before inserting the div for the grid.<br \/>\nFollowing is an example of ng-app and ng-controller<br \/>\n<code><br \/>\nng-app='myApp' ng-controller='myController'<br \/>\n<\/code><\/p>\n<p>Insert following div example in html.<br \/>\n<code><\/code><\/p>\n<div class=\"gridStyle\"><\/div>\n<p>&nbsp;<\/p>\n<h2>Step 2<\/h2>\n<p>In a javascript file, say &#8216;app.js&#8217;, define the angular module as follows with ngGrid.<br \/>\n<code><br \/>\nvar app = angular.module('myApp', ['ngGrid']);<br \/>\n<\/code><\/p>\n<h2>Step 3<\/h2>\n<p>In the controller, define the gridOptions as follows:<\/p>\n<p><code><br \/>\napp.controller('myController', ['$scope','$http', function($scope, $http){<br \/>\nconsole.log('user name : ' + $scope)<br \/>\nconsole.log('user name : ' + $http)<br \/>\n$scope.gridOptions = { data: 'candidates',<br \/>\ncolumnDefs: [<br \/>\n{field: 'name', displayName: 'Name'},<br \/>\n{field: 'lastName', displayName: 'Last Name'}<br \/>\n]<br \/>\n};<\/code><\/p>\n<p>$scope.candidates = data.candidates;<\/p>\n<p><code><br \/>\n};<br \/>\n}]);<\/code><\/p>\n<p>&nbsp;<\/p>\n<h4>Reference<\/h4>\n<ul>\n<li><a title=\"https:\/\/github.com\/angular-ui\/ng-grid\/wiki\/Getting-started\" href=\"https:\/\/github.com\/angular-ui\/ng-grid\/wiki\/Getting-started\">https:\/\/github.com\/angular-ui\/ng-grid\/wiki\/Getting-started<\/a><\/li>\n<li><a title=\"angularjs.org\" href=\"angularjs.org\">angularjs.org<\/a><\/li>\n<\/ul>\n<div class=\"twttr_buttons\"><div class=\"twttr_twitter\">\n\t\t\t\t\t<a href=\"http:\/\/twitter.com\/share?text=AngularJS+ngGrid+-+example\" class=\"twitter-share-button\" data-via=\"\" data-hashtags=\"\"  data-size=\"default\" data-url=\"https:\/\/shirishranjit.com\/blog1\/technical-posts\/javascript-world\/angularjs-nggrid-example\"  data-related=\"\" target=\"_blank\">Tweet<\/a>\n\t\t\t\t<\/div><div class=\"twttr_followme\">\n\t\t\t\t\t\t<a href=\"https:\/\/twitter.com\/shiranjit\" class=\"twitter-follow-button\" data-size=\"default\"  data-show-screen-name=\"false\"  target=\"_blank\">Follow me<\/a>\n\t\t\t\t\t<\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>ngGrid is a powerful grid library; however, there is confusion in how it works. Here is an example of ngGrid that works for the following versions: ngGrid &#8211; 2.x ng-grid-2.0.14.debug.js ng-grid-2.0.14.min.js jquery-1.8.2.js AngularJS &#8211; 1.3.14 Step 1 Make sure that &hellip; <a href=\"https:\/\/shirishranjit.com\/blog1\/technical-posts\/javascript-world\/angularjs-nggrid-example\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":817,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-884","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/shirishranjit.com\/blog1\/wp-json\/wp\/v2\/pages\/884"}],"collection":[{"href":"https:\/\/shirishranjit.com\/blog1\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/shirishranjit.com\/blog1\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/shirishranjit.com\/blog1\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shirishranjit.com\/blog1\/wp-json\/wp\/v2\/comments?post=884"}],"version-history":[{"count":11,"href":"https:\/\/shirishranjit.com\/blog1\/wp-json\/wp\/v2\/pages\/884\/revisions"}],"predecessor-version":[{"id":898,"href":"https:\/\/shirishranjit.com\/blog1\/wp-json\/wp\/v2\/pages\/884\/revisions\/898"}],"up":[{"embeddable":true,"href":"https:\/\/shirishranjit.com\/blog1\/wp-json\/wp\/v2\/pages\/817"}],"wp:attachment":[{"href":"https:\/\/shirishranjit.com\/blog1\/wp-json\/wp\/v2\/media?parent=884"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}