10

Is there a way to search a date field with smart-table? I need to filter for dates later then a given date.

1 Answer 1

16

you can set up a custom (global filter) using the st-set-filter attribute (not documentented yet)

<table st-set-filter="myFilter" st-table="rowCollection">
  ...
</table>

Then implement the custom filter

myApp.filter('myFilter',[function(){
    return function(array, expression){
       //an example
       return array.filter(function(val, index){
           return new Date(val.theDateProperty) > new Date(expression.theDateProperty) ;
       });
    }
});

where for example you have set up you input in the table

<input type="date" st-search="'theDateProperty'" />

Note the filter is global to the table, so it will be called in place of angular filter (the default one used) for very search input. So if you want other filter behaviour for different columns, you'll have to add them in your custom filter, or an other technique is to use a comparator function. You'll find more details in my comment on the pull request (18/11/2014) and a plunker

Edit:

It has been documented in the meanwhile.

Sign up to request clarification or add additional context in comments.

1 Comment

- plunker is broken; and is there a way to filter externally from the table DOM? stackoverflow.com/questions/29261957/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.