I am using the angular grid, ui-grid, located at ui-grid.info.
I am trying to make a custom filter that will filter the grid by date using date inputs controls, one for
Do you mean something like this ?
First you should include jQuery UI Datepicker
Then you will also create a directive for it:
app.directive('datePicker', function(){
return {
restrict : "A",
require: 'ngModel',
link : function(scope, element, attrs, ngModel){
$(function(){
$(element).datepicker({
changeMonth: true,
changeYear: true,
closeText: 'Clear',
showButtonPanel: true,
onClose: function () {
var event = arguments.callee.caller.caller.arguments[0];
// If "Clear" gets clicked, then really clear it
if ($(event.delegateTarget).hasClass('ui-datepicker-close')) {
$(this).val('');
scope.$apply(function() {
ngModel.$setViewValue(null);
});
}
},
onSelect: function(date){
scope.$apply(function() {
ngModel.$setViewValue(date);
});
}
});
})
}
}
})
In your columnDefs you will also need to use customer filters and filter header template:
filters:[{ condition: checkStart}, {condition:checkEnd}],filterHeaderTemplate: '
Assume you are using momentjs The filter functions will be like this:
function checkStart(term, value, row, column) {
term = term.replace(/\\/g,"")
var now = moment(value);
if(term) {
if(moment(term).isAfter(now, 'day')) return false;;
}
return true;
}
function checkEnd(term, value, row, column) {
term = term.replace(/\\/g,"")
var now = moment(value);
if(term) {
if(moment(term).isBefore(now, 'day')) return false;;
}
return true;
}