{ columns.B-6ren">
gpt4 book ai didi

c# - Kendo Grid Filter 对于日期列不能正常工作

转载 作者:太空宇宙 更新时间:2023-11-03 18:07:17 25 4
gpt4 key购买 nike

我拿了一张带有日期栏的剑道网格。如下图

@(Html.Kendo().Grid<RxConnectEntities.OrderDTO>(Model).Name("OrderList")
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Visible(false);
columns.Bound(p => p.Drug).Width(60);
columns.Bound(p => p.Quantity).Title("Quantity (gm)").Width(80);
columns.Bound(p => p.OrderedDate).Format("{0:MM/dd/yyyy}").Title("Ordered On").Width(80);
})
.Scrollable(s=>s.Height("100%"))
.Sortable()
.Groupable()
.Filterable(f => f.Extra(false).Operators(o => o.ForString(str => str.Clear().StartsWith("Starts with").Contains("Contains")).ForDate(c=>c.IsGreaterThan("Is after").IsGreaterThanOrEqualTo("Is after or equal to").IsLessThan("Is before than").IsLessThanOrEqualTo("Is before or equal to"))))
.Pageable(p => p.PageSizes(new int[]{10,20,25,30,35}).Enabled(true).Refresh(true))
.DataSource(dataSource => dataSource
.Ajax().ServerOperation(false).PageSize(25)
.Model(m => m.Id(p => p.OrderID))
))

现在,当我在 OrderedDate 上应用过滤器时,它无法正常工作。它不适用于等于条件。我不知道出了什么问题。请帮忙。

最佳答案

我认为您必须开发和检查您的属性,然后将其转换为 DateTime,并根据您的要求获取 Date 或 DateTime。

为了更清楚,请检查以下代码:将另一列设为只读列,如下所示:

[DataType(DataType.Date)]
public DateTime? UpdatedOrderedDateReadOnly
{
get
{
if (OrderedDate != null)
{
return (Convert.ToDateTime(OrderedDate).Date);
}
return null;
}
}

然后在这个只读列上应用过滤器。这将解决您的问题。

关于c# - Kendo Grid Filter 对于日期列不能正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25012346/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com