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

GridDateTimeColumn

19 Answers 451 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
sitefinitysteve asked on 01 Feb 2010, 07:21 PM
Is there any way to have GridDateTimeColumn filtering work without having to custom code anything?  I get the nice datepicker, but it never works out of the box (I assume becasue of the time being part of the datetime type?)


19 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 02 Feb 2010, 11:07 AM
Hi,

GridDateTimeColumn  handles filtering automatically,but I guess you want to filter using the time criteria as well.You can set the PickerType to DateTimePicker which will enable you to filter by date and time.

ASPX:
<telerik:GridDateTimeColumn AutoPostBackOnFilter="false"  PickerType="DateTimePicker" UniqueName="DateTimeColumn" DataField="date"
</telerik:GridDateTimeColumn>  
 

Hope this helps.

Thanks,
 Princy
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 02 Feb 2010, 12:23 PM
Hey Princy,
  Well actually I've never had the DateTimeColumn every work automatically bound to a datatime DB col.  I just want to have it show all items on Jan 9th 2010 (for example)...so I pick the date from the box and want it to AutoPostBackOnFilter to give me those dates, but it never seems to do anything.

*Edit:
Here's the col definition
<telerik:GridDateTimeColumn DataField="Modified" DataType="System.DateTime"  AllowFiltering="true" AllowSorting="true" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" 
            HeaderText="Modified" SortExpression="Modified" UniqueName="Modified" PickerType="DatePicker" > 
        </telerik:GridDateTimeColumn> 

So if I choose Jan 9th 2010 from the box, nothing happens, then if I choose equals to, I get no records (when there's actually two)....so Im assuming it because of the time being factored into the equation...when if I specify just use date, the GridDateTimeColumn should only be filtering based on the date...

Steve
0
Daniel
Telerik team
answered on 04 Feb 2010, 02:19 PM
Hello Steve,

Please examine the following thread:
http://www.telerik.com/community/forums/aspnet-ajax/grid/date-filter-improvements.aspx

I hope this helps

Best regards,
Daniel
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 09 Feb 2010, 01:48 PM
That does explain it...however if I specify a PickerType of datepicker on the column, then it should automatically assume that I do not want to filter on time, and internally handle that situation.  I can't imagine i'm the only one who needs the data of a datetime and auto filtering (i.e no extra filter code) on the column. 


Can I get that as a feature request?
0
Daniel
Telerik team
answered on 12 Feb 2010, 12:05 PM
Hello Steve,

Of course, you are not the only one asking for this functionality. I passed your feature request to our developers but I'm afraid there is no way to implement it at this point.
Excuse us for the inconvenience.

Best regards,
Daniel
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
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 12 Feb 2010, 01:43 PM
Is it really a feature request or a Bug that should be in PITS?  If the option is there to use only a DatePicker and it doesn't work because it's a DT column, thats a feature that currently is broken...

Thanks for forwarding it :)  If possible try and get it into PITS as well
0
Daniel
Telerik team
answered on 18 Feb 2010, 09:47 AM
Hello Steve,

This is not a bug in RadGrid - actually it is a limitation "by design". Nothing is broken since this functionality works exactly in the way it was originally meant to behave.

Best regards,
Daniel
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
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 18 Feb 2010, 01:07 PM
So it's by design to give us the option to filter by only date knowing full well it will fail because time is always a factor?
0
Daniel
Telerik team
answered on 24 Feb 2010, 11:32 AM
Hello Steve,

I understand, that you don't want to use the time part in your project, but this doesn't mean that everybody has the same requirements. Some clients prefer to filter by date, but considering the time part also. We can't just ignore the time part, only because the user has chosen to display the DatePicker. We wouldn't want to tamper with the data, coming from the data source - if anyone prefer to ignore the time part, he can easily achieve this manually at datasource level.
Another option is to remove the "Equal To" filter option (which depends on the time) if this is suitable for you.

I would like to underline that although I asked our developers to consider this functionality, this doesn't guarantee 100% that it will be approved. Of course, if they accept this functionailty, we will add it in PITS in a timely manner in order to make it publicly available.

Thank you for your understanding.

Kind regards,
Daniel
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
Mark DeMichele
Top achievements
Rank 1
answered on 02 Mar 2010, 01:13 PM
I was just reading this and want to put in my two cents.  I totally disagree with the Telerik response.

If you using a Date only picker type than is makes sense that if I say, I want all records equal to "7/12/2009" that what I really mean is that I want all records from "7/12/2009 12:00am" to "7/12/2009 11:59.59pm".  There's no other logical assumption.

It's only if I'm using a picker type that supplies a time where I want to do a true "Equals".

The response, "this is by design and not a bug" sometimes get's very frustrating especially when there isn't a logical reason represented, unless I'm missing something.

In my particular case, I want the user to see the times as well, but I don't think I need to give them the ability to filter on them.  It's too painful for them to do that.  The fact that they can see "all records changed on a day" is good enough, from there they can sort and view based on the times.

I can't see any reason why someone would want to say "show me all records for this day (without time)" and nothing in return.

Well, that's just my two cents and the only reason why I'm saying this is that I'm really starting to get frustrated working around tons of "by designed" features that I really consider "not by design", if you know what I mean.

P.S.  I just tried changing the PickerType to DataTimePicker.  That's not very useful.  Not it's even worse.  What good is it to have this. It basically puts rounded times in for which Equals will almost never work.

I'm already using my own custom descendant of RadGrid in order to get around other "design features".  Can you point me at the place in the code where I may be able to alter the functionality so that I can get it to filter on the entire day and not just:12:00am.
0
Daniel
Telerik team
answered on 05 Mar 2010, 05:31 PM
Hello Mark,

Thank you for your feedback.

I understand your point of view and I have passed your feature request for future consideration.

Best regards,
Daniel
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
Michael O'Flaherty
Top achievements
Rank 2
answered on 09 Apr 2012, 05:58 PM
I have been searching the forum and see a lot of requests for this. Though you consider this not a bug (I agree), it is also not functional. Your Time control in this case is useless. Regarding this statement:

"I'm already using my own custom descendant of RadGrid in order to get around other "design features". Can you point me at the place in the code where I may be able to alter the functionality so that I can get it to filter on the entire day and not just:12:00am."

Is this possible? I too want to leave the time element in the grid but filter just on the date portion. In other words, is there a way to intercept the filter request and modify the SQL filter to achieve this result? I know how to write the SQL--I just want to know where I can accomplish this.

Thanks!
0
Daniel
Telerik team
answered on 12 Apr 2012, 10:39 AM
Hello Michael,

It would be easier to use the approach demonstrated by Georgi in this forum post. Our developers will reconsider implementing time-independent filtering for one of the next releases of RadControls for ASP.NET AJAX.

Best regards,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Michael O'Flaherty
Top achievements
Rank 2
answered on 12 Apr 2012, 02:08 PM
Thanks! We prefer our solution because it allows us to display the time in the grid. In your example, it looks to me like you are chopping off the time in the display. We wanted to display the time but treat the query as a date only. Our solution allows that: http://www.telerik.com/community/forums/aspnet-ajax/grid/radgrid-datetime-filtering.aspx 
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 12 Apr 2012, 02:16 PM
Nice!  Thanks Michael

@Telerik So while we have a solution, it's a bit of a pain to have to keep implementing.  I would bet if you put it out to a poll 99% of voters would say it SHOULD work the way we're expecting...by omitting the time

At the very least make it work this way out of the box and put in a property to enable time filtering (which nobody will ever enable)
0
Michael O'Flaherty
Top achievements
Rank 2
answered on 12 Apr 2012, 02:20 PM
I agree!

In case this helps anybody else, we added logic for the <> >=, etc. This is kind of hacked together, but you get the drift:

// for columns [AssignDate] and [ReferralDate], we need some help. We need to ignore the time element in the filter query
            string ret = filter;
            string assignDate = string.Empty;
            string referralDate = string.Empty;
 
            if (filter.Contains("([AssignDate]"))
            {
                int index = filter.IndexOf("([AssignDate]");
                int firstQuote = filter.IndexOf("'", index);
                int lastQuote = filter.IndexOf("'", firstQuote + 1);
 
                if ((firstQuote > -1) && (lastQuote > -1))
                {
                    string stringToExcise = filter.Substring(index, lastQuote - index + 2);
 
                    if ((stringToExcise.Contains("IS NULL") == false) && (stringToExcise.Contains("IS NOT NULL") == false))
                    {
                        string dateToParse = filter.Substring(firstQuote + 1, lastQuote - firstQuote - 1);
                        DateTime dateTime = DateTime.Parse(dateToParse);
 
                        string filterModifier = string.Empty;
                        if (stringToExcise.Contains("<>"))
                            filterModifier = "<>";
                        else if (stringToExcise.Contains(">="))
                            filterModifier = ">=";
                        else if (stringToExcise.Contains("<="))
                            filterModifier = "<=";
                        else if (stringToExcise.Contains(">"))
                            filterModifier = ">";
                        else if (stringToExcise.Contains("<"))
                            filterModifier = "<";
                        else
                            filterModifier = "=";
 
                        assignDate = "(convert(varchar(10), [AssignDate], 101) " + filterModifier + " '" + dateTime.Month.ToString("0#") + "/" + dateTime.Day.ToString("0#") + "/" + dateTime.Year + "')";
 
                        ret = ret.Replace(stringToExcise, assignDate);
                    }
                }
            }
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 12 Apr 2012, 02:33 PM
Right, what user in his right mind wants it to auto-gen a date picker whos results do nothing...
0
Michael O'Flaherty
Top achievements
Rank 2
answered on 12 Apr 2012, 02:39 PM
Telerik was quick to point out that it worked as expected and it was not a bug. They were technically correct--however, functionally, a complete miss. Their time drop-down for this scenario just adds insult to injury. I am new to Telerik ASP (came over from the old technology called Silverlight), but for the most part, their ASP stuff is great. It is just in this case they are flat out wrong!
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 12 Apr 2012, 02:42 PM
Yeah, sorry that's what I meant :)  It "works"...technically...but generates unusable pointless results that nobody would ever want or expect.
Tags
Grid
Asked by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Answers by
Princy
Top achievements
Rank 2
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Daniel
Telerik team
Mark DeMichele
Top achievements
Rank 1
Michael O'Flaherty
Top achievements
Rank 2
Share this question
or