Filter 如何在筛选日期后重置物料表
我刚刚让我的日期范围选择器工作,它过滤表。但当我点击清除过滤器时,它不会重置表格。关于如何在清除过滤器后使用原始数据填充表,您有什么想法吗 HTMLFilter 如何在筛选日期后重置物料表,filter,angular-material,angular8,Filter,Angular Material,Angular8,我刚刚让我的日期范围选择器工作,它过滤表。但当我点击清除过滤器时,它不会重置表格。关于如何在清除过滤器后使用原始数据填充表,您有什么想法吗 HTML - 滤器 清除过滤器 TS filterTable(){ console.log(this.from); this.dataSource=新MatTableDataSource( this.dataSource.data.filter( x=> 新日期(x.createDate)>=新日期(this.from)&& 新日期(x.createD
-
滤器
清除过滤器
TS
filterTable(){
console.log(this.from);
this.dataSource=新MatTableDataSource(
this.dataSource.data.filter(
x=>
新日期(x.createDate)>=新日期(this.from)&&
新日期(x.createDate)
<div class="dateFilter">
<input matInput class="dateRange" type="date" (keypress)="keyPressNumbersDate($event)" [formControl]= "dateFilter" [(ngModel)]= "from" placeholder="mm/dd/yyyy"> - <input matInput class="dateRange" type="date" (keypress)="keyPressNumbersDate($event)" [(ngModel)]= "to" placeholder="mm/dd/yyyy">
<button (click)= 'filterTable()'>Filter</button>
<button (click)= 'clearFilters()'>Clear Filters</button>
</div>
filterTable() {
console.log(this.from);
this.dataSource = new MatTableDataSource<User>(
this.dataSource.data.filter(
x =>
new Date(x.createDate) >= new Date(this.from) &&
new Date(x.createDate) <= new Date(this.to)
)
);
}
formateDate(date: Date) {
return (
date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate()
);
}
clearFilters(){
this.dataSource.filter='';
this.from = null;
this.to = null;
}