How to use angular ui grid table
Posted By : Darshan Dang | 29-Jun-2015
What is uiGrid table ?
UI-Grid is a 100% angular grid written with no dependencies other than AngularJS. It is designed around a core grid module and features are layered on as angular modules and directives.
Using uiGrid is easy—just follow these simple steps:
<link rel="styleSheet" href="release/ui-grid-unstable.css"/> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.js"></script> <script src="/release/ui-grid-unstable.js"></script>
Include ui.grid module as a dependency in your app
- var app = angular.module('app', ['ui.grid']);
Add a css style to your app css so the grid knows it's dimensions
.myGrid { width: 500px; height: 250px; }
Add an array of data to a property on your $scope
$scope.myData = [ { "firstName": "Cox", "lastName": "Carney"... } ]
Make a Controller in seprate js like app.js
var app = angular.module('app', ['ngTouch', 'ui.grid']); app.controller('MainCtrl', ['$scope', function ($scope) { $scope.myData = [ { "firstName": "Cox", "lastName": "Carney", "company": "Enormo", "employed": true }, { "firstName": "Lorraine", "lastName": "Wise", "company": "Comveyer", "employed": false }, { "firstName": "Nancy", "lastName": "Waters", "company": "Fuelton", "employed": false } ]; }]);
Controller call in html file
<div ng-controller="MainCtrl"> <div id="grid1" ui-grid="{ data: myData }" class="grid"></div> </div>
for more refrence url is http://ui-grid.info/docs/#/tutorial/101_intro
Thanks
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Darshan Dang
Darshan is a creative UI designer with experience and capabilities to build compelling UI designs for Web and Mobile Applications. Darshan likes Punjabi songs and Travelling in Free Time .