[英]How to filter Kendo Ui Grid with DateRange?
Currently I am using Kendo Ui Grid and I try to filter by DateRange . 目前我正在使用Kendo Ui Grid,我尝试按DateRange进行过滤。 At the moment my code goes like this: 目前我的代码是这样的:
HTML: HTML:
<kendo-grid-column field="createdate" title="Creation Date" width="150">
<ng-template kendoGridFilterCellTemplate let-filter>
<app-date-range-filter-cell class="date-range-filter" [filter]="filter" field="createdate">
</app-date-range-filter-cell>
</ng-template>
</kendo-grid-column>
In my response I have createdate: "2019-04-19T15:47:48.000+0000"
and I show it in my Grid like this createdate: "19/04/2019, 18:47:48"
using: 在我的回复中,我createdate: "2019-04-19T15:47:48.000+0000"
并且我在我的网格中显示它就像这个createdate: "19/04/2019, 18:47:48"
createdate: "2019-04-19T15:47:48.000+0000"
createdate: "19/04/2019, 18:47:48"
使用:
this.createdate = this.datePipe.transform(this.createdate, 'dd/MM/yyyy, HH:mm:ss');
I need make filtering by DateRange
works only by date because Kendo DateRange works with type Date
and mine is type string
. 我需要通过DateRange
进行make过滤只能按日期工作,因为Kendo DateRange的工作类型为Date
而我的是类型string
。 Any help? 有帮助吗?
I have found my solution here. 我在这里找到了解决方案。 I did the following steps: 我做了以下步骤:
a) Converted string
dates into type Date
with: a)将string
日期转换为类型Date
:
this.createdate = new Date(this.createdate);
b) I changed the format of date in my html like that: b)我改变了我的html中的日期格式:
<kendo-grid-column field="createdate" title="Creation Date" width="150" format="{0: dd/MM/yyyy, HH:mm:ss}">
<ng-template kendoGridFilterCellTemplate let-filter>
<app-date-range-filter-cell class="date-range-filter" [filter]="filter" field="createdate">
</app-date-range-filter-cell>
</ng-template>
</kendo-grid-column>
And voila you can use DateRange
for column with dates in Kendo Ui Grid. 并且您可以将DateRange
用于Kendo Ui Grid中的日期列。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.