Rectangle 27 0

The quickest thing to do is to add another field into your (view)model that would keep formatted date.

{ Name: '', Created: '', CreatedFormatted: ''}

another apporach ... create custom comparator that would be used in filter

$filter('filter')(array, expression, comparator)

inside the comparator format date for each record and compare strings ..

javascript - How to search filter date objects with ngTable in Angular...

javascript angularjs filter ngtable
Rectangle 27 0

I am able to do it by filtering date as text .The sort functionality is also working. Below is the working example:

angular.module("tableApp", ['ngTable'])
.controller("MyCtrl", function($scope, NgTableParams) {
  $scope.data = [
    { Name: 'John', Date: new Date('2/1/2019') },
    { Name: 'Doe', Date: new Date('1/2/2014') },
    { Name: 'Jane', Date: new Date('1/1/2014') },
    { Name: 'Karthik', Date: new Date('3/1/2017') }
  ]; 
  $scope.tableParams = new NgTableParams({}, {dataset:$scope.data});
})
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.9/angular.min.js"></script>
<script src="//cdn.jsdelivr.net/angular.ngtable/1.0.0/ng-table.js"></script>
<link rel="stylesheet" href="//cdn.jsdelivr.net/angular.ngtable/1.0.0/ng-table.css" />

<div ng-app="tableApp" ng-controller="MyCtrl">
  <table ng-table="tableParams" show-filter="true" class="table">
        <tr ng-repeat="user in $data">
            <td data-title="'Name'" filter="{ 'Name': 'text' }" sortable="'Name'">
                {{user.Name}}
            </td>
            <td data-title="'Date'" filter="{ 'Date': 'text' }" sortable="'Date'">
                {{user.Date | date}}
            </td>
        </tr>
    </table>
</div>

AngularJS ngTable filtering by Date - Stack Overflow

angularjs ngtable
Rectangle 27 0

This is not an issue of the ngTable but how the underlying angular filter for 'OrderBy' works.

Just use valueOf()[0], valueOf()[1] respectively where 0 & 1 are the indexes for your inner array. Here is the html and there is no need to change your getData callback.

<table ng-table="tableParams" show-filter="true" class="table" >
    <tr ng-repeat="item in $data" height="10px">
        <td data-title="'Date'" filter="{ '0': 'text' }" sortable="valueOf()[0]">{{ item[0] | date: 'd MMM yyyy HH:mm' }}</td>
        <td data-title="'Count'" filter="{ '1': 'text' }" sortable="valueOf()[1]">{{ item[1] }}</td>
    </tr>
</table>

Please note that you don't need a translate for presenting your dates from milliseconds as this is supported by an other angular filter 'date'.

In order to achieve filtering from date you need to use a custom "comperator" function as a third argument when filtering on the controller. Something like this will do the trick

var dateComperator = function(obj, text) {
   var valueAsText = obj + '';
    if (valueAsText.length == 13) { // must be milliseconds.
      valueAsText = $filter('date')(obj, 'd MMM yyyy HH:mm');
    } 
    return !text || (obj && valueAsText.toLowerCase().indexOf(text.toLowerCase()) > -1);
};
getData: function($defer, params) {
        // use build-in angular filter
        var sortedData = params.sorting() ?
                            $filter('orderBy')($scope.tasksRunDataForTable, params.orderBy()) :
                            $scope.tasksRunDataForTable;
        var filterInfo = params.filter();
        var comparer = (filterInfo && filterInfo['0']) ? dateComparer : undefined;
        $log.log(angular.toJson(filterInfo))
        var orderedData = filterInfo ?
               $filter('filter')(sortedData, filterInfo, comparer) :
               sortedData;
        params.total(orderedData.length); // set total for recalc pagination
        $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
    }

Thanks. Looks good, except count is not getting sorted.

@abi1964 also did a fix so now the sorting works. The problem here was I was not using valueOf() correctly. It is a javascript Object method not an Array method. Sorry my mistake.

angularjs - How to sort and filter ngTable date (milliseconds) data? -...

angularjs ngtable
Rectangle 27 0

The quickest thing to do is to add another field into your (view) model that would keep formatted date.

{ Name: '', Created: '', CreatedFormatted: ''}

another apporach ... create custom comparator that would be used in filter :

$filter('filter')(array, expression, comparator)

params.filter() returns object like {Created: "Mon 12,"}

inside the comparator format date for each record and compare strings ...

javascript - How to search filter date objects with ngTable in Angular...

javascript angularjs filter ngtable