I am trying to configure ngTable in my application, but it does not support filtering by date, and I cannot figure out how to implement it. Initially, I had a date in my data as a timestamp, which allowed me to sort the column correctly due to the incremental nature of the timestamp, but obviously I cannot print September and filter the data.
// Example row data from data array { "index": 0, "id": "54587313ac91d561b246bf90", "user": "user3", "date": 1390054873445, "status": "in-progress" }
I tried setting it to a string, but when you filter or sort, it does not create asc / desc order, instead it comes to be organized in the data.
// Date output not in asc/desc if use date string September 8, 2014 September 27, 2014 September 23, 2014 September 26, 2014
I look through ngTable and find that I can change the table title, so I took a copy for editing and added some kind of custom filter or directive? Maybe I should use a different date string? I created a Plunker application using timestamp data that is filtered out for display to the user and sorted, but I would like to be able to filter by entering the month, day and / or year, i.e. 2014, September, etc.
// Example date column setup <td data-title="'Date'" sortable="'date'" filter="{ 'date': 'text' }" ng-bind="(doc.date | date:mediumDate)"></td>
UPDATE I just noticed at the bottom of ngTable.js that you can use your own filters. I eventually figured out how to load an external file into a custom filter, rather than embed ngTemplates:
<td data-title="'Date'" sortable="'date'" filter="{ 'date': 'date' }" // add name of filter (date), to the value of assoc array ng-bind="(loan.date | date:mediumDate)"></td>
or put the file in a more useful place in your application:
<td data-title="'Date'" sortable="'date'" filter="{ 'date': 'date', templateURL: '/www/app/ng-table/filters/date.html' }" ng-bind="(loan.date | date:mediumDate)"></td>
Still not sure what to do, but trying to get it to work, I made Plunker what I have, if that helps. Should there be a directive in date.html?