lorenzofox3 / Smart-Table

Code source of Smart Table module: a table/grid for Angularjs
http://lorenzofox3.github.io/smart-table-website/
1.8k stars 513 forks source link

Date Filter #792

Open Sergevia opened 7 years ago

Sergevia commented 7 years ago

Hello, Could someone update the Date Filter in the documentation, because is obsolete and the plunker does not work anymore with the latest AngularJs/UI-Boostrap?

By eg I have the following:

https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css
https://code.angularjs.org/1.6.5/angular.min.js
https://code.angularjs.org/1.6.5/i18n/angular-locale_en-us.js
https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/2.5.0/ui-bootstrap-tpls.min.js

There is a solution on the SO, but is it the optimal one? ...

MrWook commented 7 years ago

Hello @Sergevia,

it's true that the date filter is outdated. I looked a bit into it and found two things.

  1. The datepicker in this example use datepicker as a directive but this is deprecated. It is uib-datepicker now.
  2. The angular team changed something with the Filter 'filter'. Inside the custom filter is a parameter with the name expected. In the old example it contains a object with 'before' and 'after' but since 1.3.6 of Angular it is a string. From the Angular 1.3.6 changelog

Named properties in the expression object will only match against properties on the same level. Previously, named string properties would match against properties on the same level or deeper.

I wanted to create a Smart-Table binding for my date range picker, but i don't know when i have time again to create this extension

MrWook commented 7 years ago

Hello @Sergevia,

just to inform you i added the Smart-Table support to my date range picker. If you prefer to use the selection type from the example with two input fields you can copy the filter(filter) overrides from my part and adjust the datepicker with uib-datepicker. I didn't test it but i think it should work just fine.

Btw. for the changes from 1.3.6 it looks like the Filter(filter ) can't handle a date object properly anymore or i'm stupid, I don't know. But it will work with a formatted date like "2017-08-28" or what ever you prefer

jacebot commented 6 years ago

I would like to also add that on global searching if the original date object does not contain the string you are searching for it will return null. So example if I pipe a date object 2017-11-06T17:55:13.537Z to get a pretty format Nov 6th, 2017 I am not able to search for Nov, however, I can search for 11-06 and return the right data. When the table becomes null from the bad search, even after deleting the search string in the input field, the table does not recover from this. This occurs when a date object is being searched specifically, and returns null. The table will recover on a global search.

st-search == recoverable

versus

st-search="dateCreated" != recoverable