Pergunta

I have taken a Kendo Grid with date column. Like below

@(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))
))

Now when I apply filter on OrderedDate, it don't work correctly. It doesn't work for equal to condition. I don't know what's the issue. Please help.

Foi útil?

Solução

I think you have to develop and check your property and then convert it in to DateTime and based on your requirement either you should fetch Date or DateTime.

For more clarity please check below code : Make another column as readonly column like below:

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

Then apply filter on this readonly column. This will solve your issue.

Outras dicas

try the following

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

hope that this will help you, i tried it and it worked with me

regards

I struggled with this until I found the Gist on github

Here is the article on how to go about this.

Read the comments and you will see that Telerik thinks it is working as designed. Unfortunately it doesnt work for only filtering by date. Big nod to Crowbar Solutions.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top