Ui-grid (3.0.0 unstable) cellFilter with date

ui-grid (3.0.0-rc.16) does not work when using filter dates. Filtering on other fields works well.

Here goes the punker:

http://plnkr.co/edit/b9NSk0 

Try entering 2014 for any date.

Error or am I missing something?

 // main.js var app = angular.module('myApp', ['ui.grid', 'ui.grid.i18n']); app.controller('MyCtrl', function($scope) { $scope.myData = [{ eventName: "event1", eventDateRaw: new Date(1416396274368), eventDateFormatted: new Date(1416396274368) }, { eventName: "event2", eventDateRaw: new Date(1416352423803), eventDateFormatted: new Date(1416396274368) }]; $scope.gridOptions = { data: 'myData', columnDefs: [{ name: 'eventName', width: "20%" }, { name: 'eventDateRaw', width: "40%" }, { name: 'eventDateFormatted', width: "40%", cellFilter: 'date: "yyyy-MM-dd HH:mm:ss.sss"' }], enableFiltering: true }; }); 

w remy44

+5
source share
4 answers

Try adding a type:

 { name: 'eventDateFormatted', width: "40%", cellFilter: 'date: "yyyy-MM-dd HH:mm:ss.sss"', type: 'date' } 
+2
source

Try to invert your quotes, so parameters are passed using single quotes.

javascript cellFilter: "date: 'yyyy-MM-dd HH:mm:ss.sss'"

0
source

cellTemplate: '{{row.entity.delivery_month | date: "yyyy MMM"}} ',

0
source

I have no idea why this does not work in the declarative phase, but this should work:

 // main.js var app = angular.module('myApp', ['ui.grid', 'ui.grid.i18n']); app.controller('MyCtrl', function($scope) { $scope.myData = [{ eventName: "event1", eventDateRaw: new Date(1416396274368), eventDateFormatted: new Date(1416396274368) }, { eventName: "event2", eventDateRaw: new Date(1416352423803), eventDateFormatted: new Date(1416396274368) }]; $scope.gridOptions = { data: 'myData', columnDefs: [{ name: 'eventName', width: "20%" }, { name: 'eventDateRaw', width: "40%" }, { name: 'eventDateFormatted', width: "40%" }], enableFiltering: true }; $scope.gridOptions.columnDefs[2].cellFilter = "date:'dd/MM/yyyy'"; }); 

Pay attention to the last line

0
source

Source: https://habr.com/ru/post/1207218/


All Articles