Last active
January 19, 2016 15:53
-
-
Save dapangmao/78c1688a63574289bb34 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <html ng-app="app"> | |
| <head> | |
| <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.js"></script> | |
| <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular-animate.js"></script> | |
| <!-- <script src="http://ui-grid.info/docs/grunt-scripts/csv.js"></script> | |
| <script src="http://ui-grid.info/docs/grunt-scripts/pdfmake.js"></script> | |
| <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular-touch.js"></script> | |
| <script src="http://ui-grid.info/docs/grunt-scripts/vfs_fonts.js"></script> --> | |
| <script src="http://ui-grid.info/release/ui-grid.js"></script> | |
| <link rel="stylesheet" href="http://ui-grid.info/release/ui-grid.css" type="text/css"> | |
| <!-- <link rel="stylesheet" href="main.css" type="text/css"> --> | |
| <script> | |
| var app = angular.module('app', ['ui.grid', 'ui.grid.selection']); | |
| app.controller('MainCtrl', ['$http', 'uiGridConstants', function ($http, uiGridConstants) { | |
| var vm = this; | |
| vm.gridOptions = { | |
| enableRowSelection: true, | |
| selectionRowHeaderWidth: 35, | |
| rowHeight: 35, | |
| showGridFooter:true, | |
| }; | |
| // try this option | |
| vm.gridOptions.enableFiltering = true; | |
| vm.gridOptions.columnDefs = [ | |
| { name: 'id' }, | |
| { name: 'name'}, | |
| { | |
| name: 'gender', | |
| // filter: { | |
| // term: '1', | |
| // type: uiGridConstants.filter.SELECT, | |
| // selectOptions: | |
| // [ | |
| // { value: 'male', label: 'male' }, | |
| // { value: 'female', label: 'female' } | |
| // ] | |
| // }, | |
| }, | |
| { | |
| name: 'age', cellFilter: 'currency', | |
| filters: [ | |
| { | |
| condition: uiGridConstants.filter.GREATER_THAN_OR_EQUAL, | |
| placeholder: 'greater than or equal to' | |
| }, | |
| { | |
| condition: uiGridConstants.filter.LESS_THAN_OR_EQUAL, | |
| placeholder: 'less than or equal to' | |
| } | |
| ] | |
| }, | |
| { name: 'address.city' } | |
| ]; | |
| vm.gridOptions.multiSelect = true; | |
| $http.get('https://cdn.rawgit.com/angular-ui/ui-grid.info/gh-pages/data/500_complex.json').success(function(data) { | |
| vm.gridOptions.data = data; | |
| }); | |
| vm.clearAll = function() { | |
| vm.gridApi.selection.clearSelectedRows(); | |
| }; | |
| vm.gridOptions.onRegisterApi = function(gridApi){ | |
| vm.gridApi = gridApi; | |
| }; | |
| }]); | |
| </script> | |
| </head> | |
| <body> | |
| <div ng-controller="MainCtrl as c"> | |
| <button type="button" class="btn btn-success" ng-click="c.clearAll()">Clear All</button> | |
| <br/> | |
| <div ui-grid="c.gridOptions" ui-grid-selection class="grid"></div> | |
| <pre>{{c.gridApi.selection.getSelectedRows()}}</pre> | |
| </div> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment