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.

1

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.