winforms - Need to have a grid Grouped into logical groups based on date -
i'm dealing situation need group devexpress grid on basis of date column. issue is, need groups called: past, current, , future. here linq:
gridjobsummary.datasource = luke in dbcontext.jobbookings 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], goes past group.
if [job date >= today and <= (today + 1 month)], it's current.
if [job date > (today + 1 month)], it's future.
how can have grid grouped virtual group? regards.
add property "groupname" selected objects:
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, groupname = getgroupnamebydate(luke.job.jobdate) }; // ..... string getgroupnamebydate(datetime date) { var today = datetime.today; if ( date < today ) { return "past"; } else if ( date >= today && date <= today.addmonths( 1 ) ) { return "current"; } else { return "future"; } }
Comments
Post a Comment