簡體   English   中英

Kendo網格過濾器不適用於日期列

[英]Kendo Grid Filter not working properly for date column

我已將Kendo Grid與date列一起使用。 像下面

@(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;
    }
}

然后在此只讀列上應用過濾器。 這樣可以解決您的問題。

嘗試以下

.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");
    });
}))

希望這會對您有幫助,我嘗試過,它對我有用

問候

我為此奮斗直到在github上找到了Gist

這是有關如何進行此操作的文章

閱讀評論,您會發現Telerik認為它正在按設計工作。 不幸的是,它不適用於僅按日期過濾。 向Crowbar Solutions致敬。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM