var myApp = angular.module('MyApp', ['ui.grid', 'ui.grid.pagination']);
myApp.controller('MyCtrl', ['$scope', '$http', 'uiGridConstants', function ($scope, $http, uiGridConstants) {
$scope.filterOptions = {
filterText: "",
useExternalFilter: true
};
$scope.gridOptions = {
enableFiltering: true,
enablePaging: true,
showFooter: true,
paginationCurrentPage : 1,
paginationPageSizes: [3, 5, 8],
paginationPageSize: 3,
filterOptions: $scope.filterOptions,
columnDefs: [
{field: 'id', enableFiltering: false, width: '10%'},
{field: 'name'},
{field: 'group',
filter: {
type: uiGridConstants.filter.SELECT,
selectOptions: [ { value: 'grp-A', label: 'grp-A' },
{ value: 'grp-B', label: 'grp-B' },
{ value: 'grp-C', label: 'grp-C' },
{ value: 'grp-D', label: 'grp-D' }]}
},
{field: 'date', enableFiltering: false,},
{field: 'count',
filters: [
{condition: uiGridConstants.filter.GREATER_THAN,
placeholder: 'greater than'},
{condition: uiGridConstants.filter.LESS_THAN,
placeholder: 'less than'}
],
}
]
};
$http.get('../wp-content/themes/wp/json-grid.php')
.then(function onSuccess(response) {
$scope.gridOptions.data = response.data;
});
}]);
(grid.css)
.myGrid {
height: 300px;
}