C# 日期列的剑道网格筛选器工作不正常

C# 日期列的剑道网格筛选器工作不正常,c#,asp.net-mvc,kendo-ui,kendo-grid,C#,Asp.net Mvc,Kendo Ui,Kendo Grid,我已经采取了剑道网格与日期列。如下 @(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.Qu

我已经采取了剑道网格与日期列。如下

@(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))
))
@(Html.Kendo().Grid(Model).Name(“订单列表”)
.列(列=>
{
columns.Bound(p=>p.OrderID).Visible(false);
列宽(60);
列。绑定(p=>p.Quantity)。标题(“数量(gm)”)。宽度(80);
columns.Bound(p=>p.OrderedDate).Format(“{0:MM/dd/yyyy}”).Title(“Ordered On”).Width(80);
})
.可滚动(s=>s.高度(“100%”)
.Sortable()
.Groupable()
.Filterable(f=>f.Extra(false).运算符(o=>o.ForString(str=>str.Clear().StartsWith(“以开始”).Contains(“包含”)).ForDate(c=>c.IsGreaterThan(“在之后”).IsGreaterThanOrEqualTo(“在之后或等于”).IsLessThan(“在之前”).IsLessThanOrEqualTo(“在之前或等于之前”))
.Pageable(p=>p.PageSizes(新的int[]{10,20,25,30,35}).已启用(true).刷新(true))
.DataSource(DataSource=>DataSource
.Ajax().ServerOperation(false).PageSize(25)
.Model(m=>m.Id(p=>p.OrderID))
))
现在,当我在OrderedDate上应用过滤器时,它不能正常工作。它在同等条件下不起作用。我不知道是什么问题。请帮助。

尝试以下操作

.Filterable(f => f.Extra(false).Operators(o =>
{
    o.ForDate(t =>
    {
        t.Clear();
        t.IsEqualTo("Equal To");
        t.IsGreaterThan("Greater Than");
        t.IsGreaterThanOrEqualTo("Greater Than Or Equal");
        t.IsLessThan("Less Than");
        t.IsLessThan("Less Than Or Equal");
    });
}))
希望这能对你有所帮助,我试过了,而且效果很好

关于

请尝试以下方法

.Filterable(f => f.Extra(false).Operators(o =>
{
    o.ForDate(t =>
    {
        t.Clear();
        t.IsEqualTo("Equal To");
        t.IsGreaterThan("Greater Than");
        t.IsGreaterThanOrEqualTo("Greater Than Or Equal");
        t.IsLessThan("Less Than");
        t.IsLessThan("Less Than Or Equal");
    });
}))
希望这能对你有所帮助,我试过了,而且效果很好


关于

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

欲了解更多信息,请查看以下代码: 将另一列设为只读列,如下所示:

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

然后在此只读列上应用筛选器。这将解决您的问题。

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

欲了解更多信息,请查看以下代码: 将另一列设为只读列,如下所示:

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

然后在此只读列上应用筛选器。这将解决您的问题。

在github上找到要点之前,我一直在努力解决这个问题

下面是关于如何进行这项工作的建议


阅读评论,你会发现Telerik认为它是按设计工作的。不幸的是,仅按日期过滤不起作用。大力支持Crowbar解决方案。

我一直在努力解决这个问题,直到找到github的要点

下面是关于如何进行这项工作的建议


阅读评论,你会发现Telerik认为它是按设计工作的。不幸的是,仅按日期过滤不起作用。大力支持撬棍解决方案。

您是否检查了分钟和秒数是否相同?(您只显示年份、月份和日期,但内部也使用分钟、秒和分数秒)@Onabay是否存在,我可以避免它?如果没有其他可用选项,则可以在OrderDate上方使用[DataType(DataType.Date)]如果没有其他可用选项,则可以定义丢弃分钟和秒的自定义比较函数。你想试试这种方法吗?@HadiHassan我无法设置数据批注。还有别的办法吗?你检查过分钟和秒是一样的吗?(您只显示年、月和日,但在内部它也使用分、秒和秒的分数)@OnaBai有什么我可以避免的吗?使用OrderDate上方的[DataType(DataType.Date)]如果没有其他可用选项,您可以定义丢弃分和秒的自定义比较函数。你想试试这种方法吗?@HadiHassan我无法设置数据批注。还有别的办法吗?