This is a migrated thread and some comments may be shown as answers.

Filter column by hour or DateTime

5 Answers 104 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Piotr
Top achievements
Rank 1
Piotr asked on 20 Dec 2013, 01:58 PM
Hello,

I wonder whether it's possible to filter the grid  with DateTime value?

If I use DateTime I can only make the search by Date. (example below)
columns.Bound(p => p.someDateTime).Title("").Width(170).Format("{0:dd-MM-yyyy H:mm:ss}").HtmlAttributes(new { style = "text-align:center" });

The other solution would be to make two columns with Date and Time separately but then I can't filter by anything in Time. I only get blank fields. (example below)
columns.Bound(p => p.someTimeSpan).Title("").Width(170).HtmlAttributes(new { style = "text-align:center" }).ClientTemplate("<#= Hours #> : <#= Minutes  #>"); ;

5 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 21 Dec 2013, 10:01 AM
Hi Piotr,

Basically you should leave the column type to "DateTime" (the first example) instead of splitting it on two different columns. Also could you please clarify what exactly is not working when you filter by DateTime (as it's working as expected on our side)? 

Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Piotr
Top achievements
Rank 1
answered on 23 Dec 2013, 08:59 AM
OK :) 

I will try to elaborate.

For example lets say I have a record in my table: 01-10-2013 hh:mm:ss that I want to find and 1000 more other dates. Now i don't know what exact hour this was I only know the date.

The basic filtering option is:  ,,equals to:". Which won't work(If I pick only a date). I could do something like insert two dates with: ,,are later than" and ,,are earlier than". But this is not too optimal I think.

If I split the column I can sort by date. But than I can't do it by hour (I wonder whether there is some functionality that allows me to sort by like that or do I have to save the hour as string.).

I hope this clarifies everything.

Best regards.


0
Accepted
Petur Subev
Telerik team
answered on 23 Dec 2013, 09:51 AM
Hello Piotr,

I am afraid the Grid does not provide a built-in solution to what you described, you will need to either use the combination of ,,are later than" and ,,are earlier than".

Or you will have to create custom binding and change the filtering on the server to display all records for a given date (24 hours range if time part is 12:00:00).

http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/custom-binding#custom-ajax-binding


Kind Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Piotr
Top achievements
Rank 1
answered on 10 Jan 2014, 03:01 PM
Will there be a functionality that supports not obly Date but also TimeSpan search in grid in the future?
0
Vladimir Iliev
Telerik team
answered on 13 Jan 2014, 06:26 AM
Hi Piotr,

Please note that you can customize the filterable UI and include DateTimePicker instead of DatePicker as demonstrated in this example, however as the dates also contains seconds and milliseconds information using the "Equal to" filter option will still return no results. That why you should follow the guidelines provided by my colleague Petur in his previous reply if you need to support that filtering option for dates. 

Kind Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Piotr
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Piotr
Top achievements
Rank 1
Petur Subev
Telerik team
Share this question
or