Hi. Let me explain.
My database has 7 date fields. They are all the same date, I just renamed them so I can show them separetly in a Grid.
LogDate, LogYear, LogMonth, LogDay, LogDayOfWeek, LogHour, LogMinute
I format each of those columns to show only the part of the DateTime that I want to show for that column. I get the correct info in the grid. I use the GroupByMode.Text so when it is grouped, it does it properly. All of them seem to work fine except for the time formatted fields.
Hour and Minute show correctly (4 PM and 24 respectively) then i group them in my grid and they looked fine, but on closer inspection, there were two 4 PM hours showing, each with their own date. So if I did another log at 4 PM on a different day, it would have three 4 PM in my groups. The same thing happens by minute. For some reason it looks like it is grouping by date before it does the text.
I test and the text of the cells are correct. The other date parts seems to be working fine.
Please help! IG version 20102.2064
I was unable to get that working with the code I am using. So I did all my formatting in the DB and just set the fields to string instead of datetime. I would have preferred not to have changes all my views and stored procs but it was less time consuming them mucking around with the grid. I think that the grid needs to be a little more user friendly when it comes to the datetime and grouping and filtering.
Thanks.
Hello John.
I have attached a sample here where I implemented the IGroupByEvaluator interface. The grid is bound to a data table containing a column of type DateTime. There are 20 rows and I gave all of them the same time (3 PM), but 10 of them have a date of 10/1/2010 and the other 10 have a date of 10/2/2010.
When you group the grid by the LastOrderDate column you get just one group by row because it is performing the comparison on the hour instead of the whole date. The GetGroupByValue method returns just the hour portion of the date and the DoesGroupContainRow method looks at that hour that is passed in and compares it to the hour in cells date.
Please let me know if you have any questions.
Sincerely,
Charlie
Senior Developer Support Engineer
MCTS
I took a look at our code and the GroupByMode.Text case seems to check the cell 's text against the string produced by calling the parameterless ToString off the GroupByRow's Value. Since these are DateTime values, ToString will return a string that contains the date and time, so the comparison is not happening the way you intended.
I don't think this is really a bug in the grid...note that you can override the logic that determines which rows go in which groups by implementing the IGroupByEvaluator interface. You might want to do that for the time columns and make it so they only look at the time component of the date.