name: 'Date',
type: 'date',
cellFilter: 'date:"MM/dd/yyyy"',
filterHeaderTemplate: '<div class="ui-grid-filter-container" ng-repeat="colFilter in col.filters"><input type="date" ng-model="colFilter.term" style="font-size:12px"/></div>',
filters:
{
filterName: "greaterThan",
condition: uiGridConstants.filter.GREATER_THAN,
placeholder: 'greater than'
},
{
filterName: "lessThan",
condition: uiGridConstants.filter.LESS_THAN,
placeholder: 'less than'
}angular.forEach($scope.gridOptions.data, function (val) {
val.date = new Date(val.date);
});
{ field: 'DATE_TIME', name: 'Date Time', cellTooltip: true, cellFilter: 'date:\'yyyy-MM-dd\'', cellTemplate: 'ui-grid/date-cell', filterHeaderTemplate: 'ui-grid/custom-ui-grid-filter', width: '40%', filters: [ { condition: function(term, value, row, column){ if (!term) return true; var valueDate = new Date(value); return valueDate >= term; }, placeholder: 'Greater than or equal' }, { condition: function(term, value, row, column){ if (!term) return true; var valueDate = new Date(value); return valueDate <= term; }, placeholder: 'Less than or equal' } ], headerCellClass: $scope.highlightFilteredHeader } if (filter.flags.date === true) { value = new Date(value); // If the term has a dash in it, it comes through as '\-' -- we need to take out the '\'.
if (!(term instanceof Date)) { term = new Date(term.replace(/\\/g, '')); } else { // Now you can compare the two dates as DATES only without worrying about time elements. value.setHours(0,0,0,0); } } { field: 'DATE_TIME', name: 'Date Time', cellTooltip: true, cellFilter: 'date:\'yyyy-MM-dd\'', cellTemplate: 'ui-grid/date-cell', filterHeaderTemplate: 'ui-grid/custom-ui-grid-filter', width: '40%', filters: [ { condition: uiGridConstants.filter.GREATER_THAN_OR_EQUAL, placeholder: 'Greater than or equal', flags: { date: true } }, { condition: uiGridConstants.filter.LESS_THAN_OR_EQUAL, placeholder: 'Less than or equal', flags: { date: true } } ], headerCellClass: $scope.highlightFilteredHeader }