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

Grid : DateTime Format and Grouping doesn't work

2 Answers 134 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Marc-André
Top achievements
Rank 1
Marc-André asked on 02 Oct 2012, 03:24 PM
Hi,

I have a field in my grid containing a DateTime. I'm displaying only the yyyy/mm/dd, but the value behind is also containing the time.

With the Format I have no problem to display the date correctly, but when i'm grouping on this column, the grouping is using the data (With the time) and not the displayed value (yyyy/mm/dd)

So my question is : Can I set the grouping to use the DisplayedValue and not the "real" data?

Here is how I format my column :
.Bound(p => p.CreationDate).Format("{0:" + CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern + "}");

Thanks

2 Answers, 1 is accepted

Sort by
0
Marc-André
Top achievements
Rank 1
answered on 04 Oct 2012, 03:57 PM
I still have the problem, I will explain it in a different way :

I have a grid with a column containing a DateTime (Value : Tue Oct 02 2012 10:59:57 GMT-0400 (Eastern Daylight Time) ).

But in the grid I'm formatting the value to be displayed like that : 02/10/2012

When the user is grouping with this column, even if the grid displayed the "grouping name" as "02/10/2012", the group is done on the full value (Tue Oct 02 2012 10:59:57 GMT-0400 (Eastern Daylight Time)). So every group only contains 1 item since no item are created a the same second...

I hope you can help me.

Thanks a lot and have a nice day.

0
Ramiro
Top achievements
Rank 1
answered on 07 Mar 2014, 07:43 PM

Late but this can help.

columns.Bound(p => p.FechaVencimiento).Format("{0:" + System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern + "}");

Tags
Grid
Asked by
Marc-André
Top achievements
Rank 1
Answers by
Marc-André
Top achievements
Rank 1
Ramiro
Top achievements
Rank 1
Share this question
or