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

Filter Template with Two Dates issue

11 Answers 531 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 2
Jeff asked on 06 Apr 2009, 05:21 PM
Hello,
There seems to be a problem in the example with the Filter Template.  Go to your page http://demos.telerik.com/aspnet-ajax/grid/examples/programming/filtertemplate/defaultcs.aspx and select 3/27/1998 in the From DatePicker.  You should get 98 records.  Select 5/5/1998 from the To DatePicker.  You should get 826 records.  It seems to ignore the From DatePicker after you change the To DatePicker.  If you order by the Order Date ascending, you will notice that the grid has records with dates before 3/27/1998.  Is there any fix for this?  I've implemented this in a RadGrid using the exact same structure and have the same problem.  It seems like I would need to use Between instead of GreaterThanorEqualTo and LessThanOrEqualTo but I'm not sure how to reference both dates.
Any help would be greatly appreciated.
Thanks,
Jeff Sager

11 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 09 Apr 2009, 11:16 AM
Hello Jeff,

Thank you for the report - you are absolutely right! The date range filter for the 'OrderDate' column should use between filter instead of GreaterThanOrEqualTo/LessThanOrEqualTo combination.

I updated the corresponding RadGrid demo based on your feedback and the date range filter should honor the min/max date for both fields. Review the modified version of the implementation for more details. I updated your Telerik points for drawing our attention to this detail.

Kind regards,
Sebastian
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Yen
Top achievements
Rank 1
answered on 09 Apr 2009, 09:15 PM
Hi Sebastian,

That was very helpful.  I notice that the "Between" filter does not work for a GridDateTime column, but only for a GridBoundColumn.  I got a "The string was not recognized as a valid DateTime".  Do you have any explanation as to why that may be the case?

Thanks,

Yen
0
Sebastian
Telerik team
answered on 10 Apr 2009, 08:13 AM
Hello Yen,

Indeed the built-in GridDateTimeColumn do not allow between filter since the parsing mechanism of the date input (part of the date picker used for filtering) allows merely one date to be entered. To apply 'Between' filter you should either use the approach with two pickers in the filter template from the demo (OrderDate column) or built-in GridBoundColumn with textbox filter.

Kind regards,
Sebastian
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Yen
Top achievements
Rank 1
answered on 12 Apr 2009, 03:50 AM

Hi Sebastian & Telerik:

As a further question regarding using the "Between" filter with dates, am I correct that the filter takes into account the time as well?  Specifically, I have the following client-side filter in a GridBoundColumn of type DateTime:

tableView.filter("Modified""4/4/2009" + " " + "4/9/2009", Telerik.Web.UI.GridFilterFunction.Between); 

The results include 4/9/2009 12:00AM, but not values such as 4/9/2009 2:19PM.  So when given just the date, it seems the filter assumes a time of 0:00.

How can I specify the time in the filter?  I've tried date strings which include AM/PM time as well as 24-hour time without success.

Any input would be greatly appreciated.

Thanks,

Yen

0
Sebastian
Telerik team
answered on 14 Apr 2009, 02:00 PM
Hello Yen,

Actually it describes expected behavior. As you pointed the filtered result depends not only on the date, but the time as well. In this case, the grid can filter only the data bound to it. In other words, if the data field in the database is datetime, it is normal for the grid to compare the time values too.

To achieve filtering based only on date and if the time is not important for further filtration, you can easily convert the datetime field into a date and return it as a date type only. The framework will convert it to a DateTime type, but in this case the time will be set to midnight.

A project which shows how to accomplish this task is attached to this thread (see the SELECT query for details).

Best regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Yen
Top achievements
Rank 1
answered on 14 Apr 2009, 08:41 PM
Hi Sebastian,

Thank you for your reply.  The sample is helpful.

I guess what I really want to know is that, since filtering is time-sensitive, would it be possible to specify a time in the filter?  That is, I don't always want to filter a datetime value at midnight.  Instead, I want to filter at the actual time.  As I mentioned, this is the current filter I have:

tableView.filter("Modified", "4/4/2009" + " " + "4/9/2009", "Between");  

For example, what I want to filter is from "4/4/2009 8:00am" to "4/9/2009 8:00am".  I tried to specify a time in the "from" and "to" field without any effect.

Is there a way to achieve this?

Thanks,

-Yen
0
Sebastian
Telerik team
answered on 15 Apr 2009, 07:59 AM
Hello Yen,

Unfortunately I do not think that such type of datetime filtering is attainable. If you succeed implementing this type of filter with custom SELECT query (returning filtered set of results based on date with time values) using the MS GridView instance, please share it with us and we will gladly help you transform it to work with our web grid.

Kind regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Anish
Top achievements
Rank 1
answered on 12 Aug 2013, 04:58 AM
hi
I use date picker as filter template for one of my column. It is not get filtered because of different format issue of data set coming from server and system date format settings. without converting data set format and system format is it possible to fix this.

Thanks &Regards
Anish
0
Maria Ilieva
Telerik team
answered on 14 Aug 2013, 02:27 PM
Hi Anish,

I would suggest you to use DateTimeColumn and set the appropriate DataFormatString in order to apply the filtering functionality properly.

Regards,
Maria Ilieva
Telerik
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 the blog feed now.
0
Anish
Top achievements
Rank 1
answered on 16 Aug 2013, 04:54 AM
Hi Maria,


I changed my coloumn to GridDateTimeColumn as u mentioned but i have two issues

1.How to set DataFormatString in aspx page from a session variable rather than using in item databound as mentioned below
 if (e.Item is GridDataItem)
                {
                    GridColumnCollection cols = e.Item.OwnerTableView.Columns;
                    foreach (GridColumn col in cols)
                    {
                        string type = col.ColumnType.ToString();
                        if (type == "GridDateTimeColumn")
                        {
                            GridDateTimeColumn coluna = (GridDateTimeColumn)col;
                            coluna.DataFormatString = "{0:" + ShipmateUtilities.UtilityLayer.SessionEx.UserDateFormat + "}";
                        }
                    }

2.How to set Mandatory symbols to the GridDateTimeColumn which i used in template coloumn(Refer Attachment)

Regards
Anish Sethu
SBNT


0
Milena
Telerik team
answered on 20 Aug 2013, 12:17 PM
Hello,

The last post of the following forum threat demonstrates a possible solution for the first problem:
http://www.telerik.com/community/forums/aspnet-ajax/grid/dataformatstring-for-radgrid.aspx

Additionally, you can review this help topic.

In regard of your second question, you can use the built-in validation of RadGrid to validate GridColumn. More information about this functionality could be found here.

Regards,
Milena
Telerik
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 the blog feed now.
Tags
Grid
Asked by
Jeff
Top achievements
Rank 2
Answers by
Sebastian
Telerik team
Yen
Top achievements
Rank 1
Anish
Top achievements
Rank 1
Maria Ilieva
Telerik team
Milena
Telerik team
Share this question
or