how to use angularjs data grid ng-grid

How to use AngularJs ui-grid or ng-grid?

The ng-grid started Steps are        Click for live plnker demo

1.Add references are 
      jQuery: go to http://code.jquery.com/ 
      
     AngularJs : go to http://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.min.js 
     
     ngGrid : go to https://github.com/angular-ui/ng-grid 

2. Need to declare application app module and add ui.grid/ngGrid i.e.
1
var app =angular.module('myngGridApp',['ui.grid']);
var app =angular.module('myngGridApp',['ui.grid']);

3. Need to add style(gridStyle) and ng-grid in the display div. i.e.
1
<div class="gridStyle" ng-grid="gridOptions"></div>
<div class="gridStyle" ng-grid="gridOptions"></div>
Css code-sample
1
2
3
4
5
6
//This is ngGrid css
   .ngGridStyle {
      border: 2px solid green;
      width: 500px;
      height: 220px;
    }
//This is ngGrid css
   .ngGridStyle {
      border: 2px solid green;
      width: 500px;
      height: 220px;
    }
The HTML code-sample
1
2
3
4
5
//This is HTML code-sample
<div ng-controller="ngGridController">
  <div class="ngGridStyle" ng-grid="ngGridView"></div>
</div>
//This is HTML code-sample

<div ng-controller="ngGridController">
  <div class="ngGridStyle" ng-grid="ngGridView"></div>
</div>
The AngularJs code-sample.
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//This is AngularJs code-sample
 var app = angular.module('ngGridApp', ['ngGrid']);
        app.controller('ngGridController', function ($scope) {
            $scope.empDetail = [{
                Name: "Anil",
                Age: 50,
                Adress: ' Kushinagar, UP, India'
            }, {
                Name: "Sunil",
                Age: 43,
                Adress: ' Kushinagar, UP, India'
            }, {
                Name: "Sushil",
                Age: 27,
                Adress: ' Kushinagar, UP, India'
            }, {
                Name: "Reena",
                Age: 29,
                Adress: ' Kushinagar, UP, India'
            }, {
                Name: "Aisha",
                Age: 34,
                Adress: ' Kushinagar, UP, India'
            }];
            $scope.ngGridView = {
                data: 'empDetail',
                showGroupPanel: true,
                jqueryUIDraggable: true
            };
        });
//This is AngularJs code-sample

 var app = angular.module('ngGridApp', ['ngGrid']);
        app.controller('ngGridController', function ($scope) {
            $scope.empDetail = [{
                Name: "Anil",
                Age: 50,
                Adress: ' Kushinagar, UP, India'
            }, {
                Name: "Sunil",
                Age: 43,
                Adress: ' Kushinagar, UP, India'
            }, {
                Name: "Sushil",
                Age: 27,
                Adress: ' Kushinagar, UP, India'
            }, {
                Name: "Reena",
                Age: 29,
                Adress: ' Kushinagar, UP, India'
            }, {
                Name: "Aisha",
                Age: 34,
                Adress: ' Kushinagar, UP, India'
            }];

            $scope.ngGridView = {
                data: 'empDetail',
                showGroupPanel: true,
                jqueryUIDraggable: true
            };
        });
The Full example code-sample
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//The Full example code-sample
 <!doctype html>
<html ng-app="ngGridApp">
<head>
    <title>Example - www.code-sample.com</title>
    <link rel="stylesheet" type="text/css" href="http://angular-ui.github.com/ng-grid/css/ng-grid.css" />
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.0-rc.1/angular.min.js"></script>
    <script type="text/javascript" src="http://angular-ui.github.com/ng-grid/lib/ng-grid.debug.js"></script>
    <style>
        .ngGridStyle {
            border: 2px solid green;
            width: 500px;
            height: 220px;
        }
    </style>
    <script>
        var app = angular.module('ngGridApp', ['ngGrid']);
        app.controller('ngGridController', function ($scope) {
            $scope.empDetail = [{
                Name: "Anil",
                Age: 50,
                Adress: ' Kushinagar, UP, India'
            }, {
                Name: "Sunil",
                Age: 43,
                Adress: ' Kushinagar, UP, India'
            }, {
                Name: "Sushil",
                Age: 27,
                Adress: ' Kushinagar, UP, India'
            }, {
                Name: "Reena",
                Age: 29,
                Adress: ' Kushinagar, UP, India'
            }, {
                Name: "Aisha",
                Age: 34,
                Adress: ' Kushinagar, UP, India'
            }];
            $scope.ngGridView = {
                data: 'empDetail',
                showGroupPanel: true,
                jqueryUIDraggable: true
            };
        });
    </script>
</head>
<body ng-controller="ngGridController">
    <div class="ngGridStyle" ng-grid="ngGridView"></div>
</body>
</html>
//The Full example code-sample

 <!doctype html>
<html ng-app="ngGridApp">
<head>
    <title>Example - www.code-sample.com</title>
    <link rel="stylesheet" type="text/css" href="http://angular-ui.github.com/ng-grid/css/ng-grid.css" />
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.0-rc.1/angular.min.js"></script>
    <script type="text/javascript" src="http://angular-ui.github.com/ng-grid/lib/ng-grid.debug.js"></script>
    <style>
        .ngGridStyle {
            border: 2px solid green;
            width: 500px;
            height: 220px;
        }
    </style>
    <script>
        var app = angular.module('ngGridApp', ['ngGrid']);
        app.controller('ngGridController', function ($scope) {
            $scope.empDetail = [{
                Name: "Anil",
                Age: 50,
                Adress: ' Kushinagar, UP, India'
            }, {
                Name: "Sunil",
                Age: 43,
                Adress: ' Kushinagar, UP, India'
            }, {
                Name: "Sushil",
                Age: 27,
                Adress: ' Kushinagar, UP, India'
            }, {
                Name: "Reena",
                Age: 29,
                Adress: ' Kushinagar, UP, India'
            }, {
                Name: "Aisha",
                Age: 34,
                Adress: ' Kushinagar, UP, India'
            }];

            $scope.ngGridView = {
                data: 'empDetail',
                showGroupPanel: true,
                jqueryUIDraggable: true
            };
        });
    </script>
</head>
<body ng-controller="ngGridController">
    <div class="ngGridStyle" ng-grid="ngGridView"></div>
</body>

</html>
ANIL SINGH

Hey! I'm Anil Singh. I author this blog. I'm Active Blogger, Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
http://www.code-sample.com
http://www.code-sample.xyz

You Might Also Like
Post a Comment
www.code-sample.com/. Powered by Blogger.