Web Programming examples

Google Maps,AngularJS

AngularJS ng-grid cellFilter

  • AngularJS : 1.2.23
  • Bootstrap : 3.x
  • ng-grid : 2.0.13
  • include file
  • ng-grid.min.css,jquery.js,angular.min.js,ng-grid.min.js,ui-bootstrap-tpls-0.11.0.min.js
<link href="http://www.example.com/wp/wp-content/themes/ang/css/ng-grid.min.css" rel="stylesheet">
<link href="http://www.example.com/wp/wp-content/themes/ang/css/grid1.css" rel="stylesheet">
<script type='text/javascript' src='http://www.example.com/wp/wp-content/themes/ang/js/ng-grid.min.js'></script>
<script type='text/javascript' src='http://www.example.com/wp/wp-content/themes/ang/js/grid1.js'></script>
<div ng-controller="MyCtrl">
  <div class="row">
    <div class="col-sm-12">
      <div class="gridStyle" ng-grid="gridOptions">
      </div>
    </div>
  </div>
</div>
var myApp = angular.module('googleMapApp', ['ui.bootstrap','ngGrid']);

myApp.controller('MyCtrl', function($scope) {
    $scope.myData = [
      {name: "product-A", day: "2014-08-12", price: 50, avg: 30.5422},
      {name: "product-B", day: "2014-08-15", price: 43, avg: 52.4411},
      {name: "product-C", day: "2014-09-11", price: 27, avg: 21.1190},
      {name: "product-D", day: "2014-07-23", price: 29, avg: 34.8741},
      {name: "product-E", day: "2014-09-19", price: 27, avg: 19.8000}
    ];

    $scope.gridOptions = {
      data: 'myData',
      columnDefs: [
        {field: 'name', cellFilter: 'uppercase'},
        {field: 'day', cellFilter: 'date: "mediumDate"'},
        {field: 'price', cellFilter: 'currency'},
        {field: 'avg', cellFilter: 'number: 2'}
      ]
    };
});

One thought on “AngularJS ng-grid cellFilter”

Comments are closed.