有没有一种方法可以在智能表格中搜索日期字段?我需要过滤比给定日期晚的日期。
有没有一种方法可以在智能表格中搜索日期字段?我需要过滤比给定日期晚的日期。
你可以使用st-set-filter
属性(尚未记录)设置自定义的(全局筛选器)。
<table st-set-filter="myFilter" st-table="rowCollection">
...
</table>
然后实现自定义过滤器
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) ;
});
}
});
例如,在表格中设置了输入,
<input type="date" st-search="'theDateProperty'" />
请注意,该过滤器对整个表格全局生效,因此将替换每个搜索输入的默认angular过滤器。因此,如果您想要不同列的其他过滤器行为,则需要在自定义过滤器中添加它们,或者另一种技术是使用比较器函数。您可以在我的拉取请求(2014年11月18日)的评论和plunker中找到更多详细信息。
编辑:
同时已经有文档记录了该功能。