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

[Solved] Q1: DateTime filtering problem

13 Answers 305 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Akzhol The Kyrgyz
Top achievements
Rank 1
Akzhol The Kyrgyz asked on 13 Mar 2010, 12:18 PM
Hi, I've several problems regarding datetime filtering, using server-side binding.
I've organized problems below in two categories (Nullable DateTime and NonNullable DateTime)


  1. Nullable DateTime filtering
  • <% Html.Telerik().Grid(Model)
            .Name("uye")
            .Columns(column =>
                {
                    column.Add(item => item.Member.TCK);
                    column.Add(item => item.Member.Ad);
                    column.Add(item => item.Member.Soyad);
                    column.Add(item => item.Member.Teskilat.City.Name).Title("İl"); ;
                    column.Add(item => item.Member.Teskilat.District.Name).Title("İlçe");
                    column.Add(item => item.OperationType.Name).Title("İşlem Türü");
                    column.Add(item => item.MemberOperationStatuse.Name).Title("Karar");
                    column.Add(item => item.KararNo);
                    column.Add(item => item.KararTarihi).Format("{0: dd-MM-yyyy}");
                }
                )
            .Render();
        %>
  • Explorer and Chrome: OK, but => When you apply filter and later open filter popup, filtered field is not populated correctly. For example, instead of 02-03-2010 I see /Date(1267567200000)/ (So date object is not constructed from milliseconds)
  • Firefox 3.5.8 : If I remove Format("{0: dd-MM-yyyy}"); it's working same as in IE and Chrome. Else the url constructed is:
                                http://localhost:4964/TBS/MemberOperation?uye-page=1&uye-orderBy=~&uye-groupBy=~&uye-filter=KararTarihi~gt~datetime%27NaN-NaN-NaNT12-NaN-NaN%27
                              So can not parse the "date" NaN-NaN-NaNT12-NaN-NaN



  2. NonNullable DateTime filtering (IE 7, Firefox 3.5.8, Chrome)
  •       <% Html.Telerik().Grid(Model)
            .Name("Toplantilar")
            .Columns(column =>
                {
                    column.Add(item => item.MeetingType1.Name).Title("Toplantı türü");
                    column.Add(item => item.MeetingType1.RegionType1.Name).Title("Bölge");
                    column.Add(item => item.Adress).Title("Adres").Sortable(false);
                    column.Add(item => item.City.Name).Title("İl");
                    column.Add(item => item.District.Name).Title("İlçe");
                    column.Add(item => item.Date).Title("Tarih") ;
                }
                )
            .Render();
                        %>
Getting Exception
[SqlTypeException: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.]
   System.Data.SqlTypes.SqlDateTime.FromTimeSpan(TimeSpan value) +4836011
   System.Data.SqlTypes.SqlDateTime.FromDateTime(DateTime value) +200
   System.Data.SqlClient.MetaType.FromDateTime(DateTime dateTime, Byte cb) +46
   System.Data.SqlClient.TdsParser.WriteValue(Object value, MetaType type, Byte scale, Int32 actualLength, Int32 encodingByteSize, Int32 offset, TdsParserStateObject stateObj) +4841445
   System.Data.SqlClient.TdsParser.TdsExecuteRPC(_SqlRPC[] rpcArray, Int32 timeout, Boolean inSchema, SqlNotificationRequest notificationRequest, TdsParserStateObject stateObj, Boolean isCommandProc) +4297
   System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +954
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +162
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +32
   System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +141
   System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +12
   System.Data.Common.DbCommand.ExecuteReader() +12
   System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult) +332
   System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries) +113
   System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query) +344
   System.Data.Linq.DataQuery`1.System.Linq.IQueryProvider.Execute(Expression expression) +26
   Telerik.Web.Mvc.Extensions.QueryableExtensions.Count(IQueryable source) +337
   Telerik.Web.Mvc.Extensions.QueryableExtensions.ToGridModel(IQueryable queryable, Int32 page, Int32 pageSize, IList`1 sortDescriptors, IEnumerable`1 filterDescriptors, IEnumerable`1 groupDescriptors) +251
   Telerik.Web.Mvc.UI.GridDataProcessor.EnsureDataSourceIsProcessed() +297
   Telerik.Web.Mvc.UI.GridDataProcessor.get_ProcessedDataSource() +60
   Telerik.Web.Mvc.UI.Grid`1.WriteBody(IGridHtmlBuilder`1 builder, IHtmlNode parentTag) +1708
   Telerik.Web.Mvc.UI.Grid`1.WriteHtml(HtmlTextWriter writer) +3337
   Telerik.Web.Mvc.UI.ViewComponentBase.Render() +157
   Telerik.Web.Mvc.UI.ViewComponentBuilderBase`2.Render() +74
   ASP.areas_tbs_views_meeting_index_aspx.__RenderContent2(HtmlTextWriter __w, Control parameterContainer) in c:\Documents and Settings\Akzhol\Belgelerim\Visual Studio 2008\Projects\AKBIS_Telerik_Test\src\AKBIS\Areas\TBS\Views\Meeting\Index.aspx:29
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +256
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
   System.Web.UI.Control.Render(HtmlTextWriter writer) +10
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   ASP.areas_tbs_views_shared_site_master.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in c:\Documents and Settings\Akzhol\Belgelerim\Visual Studio 2008\Projects\AKBIS_Telerik_Test\src\AKBIS\Areas\TBS\Views\Shared\Site.Master:55
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +256
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
   System.Web.UI.Control.Render(HtmlTextWriter writer) +10
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
   System.Web.UI.Page.Render(HtmlTextWriter writer) +29
   System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer) +71
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1266

Urls constructed are:
  • http://localhost:4964/TBS/Meeting?Toplantilar-page=1&Toplantilar-orderBy=~&Toplantilar-groupBy=~&Toplantilar-filter=Date~lt~datetime'2010-03-02T12-00-00'
  • http://localhost:4964/TBS/Meeting?Toplantilar-page=1&Toplantilar-orderBy=~&Toplantilar-groupBy=~&Toplantilar-filter=Date%7Elt%7Edatetime%272010-03-03T12-00-00%27

When I add Format("{0: dd-MM-yyyy}") to NonNullable DateTime it begins to give unable to parse NaN-NaN-NaNT12-NaN-NaN error.


So what I can conclude is that
1) Filtering fields is not correctly populated back (see image)
2) Adding Format to datetime causes NaN-NaN-NaNT12-NaN-NaN url sometimes.
3) NonNullable DateTime filtering does NOT work

Please help me to solve these problems.

Thanks and Regards

13 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 15 Mar 2010, 05:48 PM
Hi Akzhol The Kyrgyz,

I was able to reproduce both problems and I confirm those are bugs. Find attached a hotfix version which should resolve those issues.

Regards,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Akzhol The Kyrgyz
Top achievements
Rank 1
answered on 19 Mar 2010, 02:42 PM
Hi, Atanas
Thank you very much for your qucik response and support.
I really appreciate it.

You've sent me a binary solution, is it possible to get source code of this release. I need to apply some other changes, that I got from other threads in this forum.

Thanks Again.
Regards



0
Akzhol The Kyrgyz
Top achievements
Rank 1
answered on 04 Apr 2010, 10:17 AM
Hi, Atanas

I'm still waiting for the source code. Could you please point me to a place where I can downlod the fixpack.
Thanks a lot.
0
Accepted
Atanas Korchev
Telerik team
answered on 08 Apr 2010, 08:07 AM
Hello Akzhol The Kyrgyz,

I am sending you the latest internal drop of the source code. It is for newer version than the one attached before but still contains the relevant fixes.

Regards,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Bob
Top achievements
Rank 1
answered on 05 May 2010, 08:53 PM
Hi Atanas,

I am also having a problem filtering by a datetime field. I have downloaded the 1.315 hotfix, but I still have the same problem. Perhaps I have not applied the hotfix correctly. I replaced the 2010.1.309 directory in Scripts with the 2010.1.315 directory. This gave me syntax errors about jquery-1.4.2.min.js being missing. I tried copying the scripts from 2010.1.315 to the Scripts directory, but then I had the original problem again. My date fields are not null in the database, and I am formatting them (server side grid) with .Format("{0:d}").

When I try to filter by date, I get a SQL error about the date not being valid.
0
Atanas Korchev
Telerik team
answered on 06 May 2010, 08:04 AM
Hi Bob,

I suggest you try the latest build attached to this forum thread:
http://www.telerik.com/community/forums/aspnet-mvc/grid/grid-clienttemplate-workaround-problem.aspx

If the problem persists please let us know how to reproduce it locally.

Regards,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Bob
Top achievements
Rank 1
answered on 06 May 2010, 03:35 PM
Thanks, Atanas, for your very fast response and working solution!
0
RE
Top achievements
Rank 1
answered on 04 Jun 2010, 12:52 PM
Hello your link to the solution is not working. Can you please provide the link?
I have the same problem with the date in filter option. Date showing as /Date(1262732400000)/

Regards,

Reggie
0
Sebastian
Telerik team
answered on 04 Jun 2010, 01:08 PM
Hi RE,

The link from Atanas' previous post should be OK now and you should be able to navigate to the corresponding forum post.

Best regards,
Sebastian
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
RE
Top achievements
Rank 1
answered on 04 Jun 2010, 01:08 PM
Thx, it's working now!
0
Gisela
Top achievements
Rank 1
answered on 16 Jun 2010, 11:53 AM
Hi guys,

But If you have a DateTime with hour, minutes and seconds also, the "equals" filter won't find rows with this date right? I mean, when you pick a date on Datepicker input, It's, for example, 14/04/2010. If you have 14/04/2010 16:40, the grid won't match the date for equals filter. I tried to format the property but it doesn't work :(

Thanks!

Re-Post: Probably It makes sense because is not the same date. But It could be better if you could specify the time also.
0
Georgi Krustev
Telerik team
answered on 16 Jun 2010, 12:19 PM
Hello Gisela Torres,

Unfortunately, currently it is not possible to filter by date and time. This is expected, because filter menu uses DatePicker in order to allow entering only correct dates. If we decide to develop DateTimePicker component, the requested functionality will be available.

Greetings,
Georgi Krustev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Gisela
Top achievements
Rank 1
answered on 16 Jun 2010, 12:36 PM
Thanks Georgi for your very fast response :) It makes sense for me.

Cheers! 
Tags
Grid
Asked by
Akzhol The Kyrgyz
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Akzhol The Kyrgyz
Top achievements
Rank 1
Bob
Top achievements
Rank 1
RE
Top achievements
Rank 1
Sebastian
Telerik team
Gisela
Top achievements
Rank 1
Georgi Krustev
Telerik team
Share this question
or