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

  1. 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

About Author

Author Image
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 .

Request for Proposal

Name is required

Comment is required

Sending message..