In order to show ng-grid you must do this:
- add 'ngGrid' to app definition like this:
var app = angular.module('AngularAuthApp', ['ngRoute', 'LocalStorageModule', 'angular-loading-bar', 'ngGrid']);
- Add custom height to css like this:
.gridStyle {
border: 1px solid rgb(212,212,212);
/*width: 800px;*/
height: 400px;
}
If you don't do this table will shrink and will not display anything.
- If you want to group column be abowe other rows and dont go over them add this to css:
.ngGroupPanel {
overflow: visible;
}
- Add this to your code in this order:
<link rel="stylesheet" type="text/css" href="http://angular-ui.github.com/ng-grid/css/ng-grid.min.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js"></script>
<script type="text/javascript" src="http://angular-ui.github.com/ng-grid/lib/ng-grid.min.js"></script>
- Add gridOptions, number of columns does not need to be as in JSON array, remind to add $scope.customerData before calling this code:
$scope.gridOptions = {
data: 'customerData',
showGroupPanel: true,
columnDefs: [{ field: 'name', displayName: 'Name' , width: '15%'},
{ field: 'city', displayName: 'City', width: '15%' },
{ field: 'address', displayName: 'Address', width: '15%' },
{ field: 'contactNo', displayName: 'Contact No', width: '15%' },
{ field: 'emailId', displayName: 'Email Id', width: '15%' },
{ displayName: 'Options', cellTemplate: '<input type="button" ng-click="setScope(row.entity,\'edit\')" name="edit" value="Edit"> <input type="button" ng-click="DeleteUser(row.entity.id)" name="delete" value="Delete">', width: '25%' }
]
};
No comments:
Post a Comment