I’m dealing with a situation where I need to group my DevExpress grid on the basis of a date column. The issue is, I need my groups to be called: Past, Current, and Future. Here is the LINQ:
GridJobSummary.DataSource = from luke in DbContext.JobBookings
where luke.LocumID == LocumID
orderby luke.Job.JobDate descending
select new {
luke.JobID,
luke.Job.JobDate,
ClientID = luke.Job.Branch.ClientID,
ClientName = String.Format("{0} ({1})", luke.Job.Branch.Client.Name, luke.Job.Branch.Client.Number),
BranchID = luke.Job.BranchID,
BranchName = String.Format("{0} ({1})", luke.Job.Branch.Number, luke.Job.Branch.Number),
JobBookingStatusName = luke.JobBookingStatus.Name
};
GridJobSummaryView.Columns["JobID"].Visible = false;
GridJobSummaryView.Columns["ClientID"].Visible = false;
GridJobSummaryView.Columns["BranchID"].Visible = false;
GridJobSummaryView.Columns["JobDate"].DisplayFormat.FormatType = FormatType.DateTime;
GridJobSummaryView.Columns["JobDate"].DisplayFormat.FormatString = "ddd, dd-MMM-yyyy";
GridJobSummaryView.Columns["JobDate"].SortOrder = ColumnSortOrder.Ascending;
Now,
If [job date < Today], it goes into Past group.
If [job date >= Today and <= (Today + 1 Month)], it’s Current.
If [job date > (Today + 1 Month)], it’s Future.
How can I have my grid grouped into this virtual group? Regards.
Add property “GroupName” to the selected objects: