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

Group by date.month

1 Answer 140 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mohamed Nazmi
Top achievements
Rank 1
Mohamed Nazmi asked on 08 Oct 2009, 07:35 PM
Greetings
I have an application that i am migrating to use rad winform controls
One of my gridviews has a date column, the whole table holds 1 record per day
I want to group by this column but by months not days

I am using SQL server 2008 as DB holder and LTS as data layer
note that i can't use Linq to do that grouping as it will make the table uneditable

1 Answer, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 14 Oct 2009, 09:34 AM
Hi Mohamed Nazmi,

You can use CustomDataOperation for this behavior. Please view CustomDataOperation in our example application. You must make CustomGrouping and handle CustomGrouping event of RadGridView.

void gridView_CustomGrouping(object sender, GridViewCustomGroupingEventArgs e)
{
    DateTime date1 = e.CellValue1 as DateTime;
    DateTime date2 = e.CellValue2 as DateTime;
 
    if (date1 != null && date2 != null)
    {
        if (date1.Year == date2.Year && date1.Month == date2.Month)
        {
            e.SortResult = 0;
            return;
        }
 
        e.SortResult = date2.CompareTo(date2);
    }

Best wishes,
Julian Benkov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Mohamed Nazmi
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Share this question
or