Hello,
I have problem to arrange the group headers for my grid and print them I like. The grid has 2 bands. Each band has 1 column with deparment name (band0) or employee name (band1) followed by 1 columns for every day within a date range up to 1 year.
After a first group for placeholder for the department column I like to have 3 header groups: a month-group over all columns in the same month. a week-numer-group within the month-group and a dayOfWeek-group within the month-group (see attached picture).
But as you can see (attached pic) my groups have different width and are not aligned to the month-group.
My code snipped looks as follows:
CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentUICulture;UltraGridGroup groupMonth = null;UltraGridGroup groupWeekNum = null;UltraGridGroup groupWeekDay = null;try { // enable label sizing band0.Layout.Override.AllowRowLayoutLabelSizing = RowLayoutSizing.Both; // department group UltraGridGroup groupOrg = band0.Groups.Add( "GroupOrg" ); groupOrg.Header.Caption = " "; groupOrg.Hidden = false; groupOrg.RowLayoutGroupInfo.OriginX = 0; groupOrg.RowLayoutGroupInfo.OriginY = 0; groupOrg.RowLayoutGroupInfo.SpanX = 1; groupOrg.RowLayoutGroupInfo.SpanY = 6; // department column UltraGridColumn col = band0.Columns[FormPlanning.KeyCol_Organisation]; col.RowLayoutColumnInfo.OriginX = 0; col.RowLayoutColumnInfo.OriginY = 0; col.RowLayoutColumnInfo.SpanX = 1; col.RowLayoutColumnInfo.SpanY = 6; col.RowLayoutColumnInfo.ParentGroup = groupOrg; // col counter for date columns int dayCount = 1; for ( DateTime date = this.servicePlan.OpenInfo.OpenRange.From; date <= this.servicePlan.OpenInfo.OpenRange.To; date = date.AddDays( 1 ) ) { string colKey = date.ToShortDateString(); // month-group string key = string.Format( "GroupMonth{0}", date.Month ); if ( !band0.Groups.Exists( key ) ) { DateTime endOfMOnth = new DateTime( date.Year, date.Month, DateTime.DaysInMonth( date.Year, date.Month ) ); groupMonth = band0.Groups.Add( key ); groupMonth.Header.Caption = cultureInfo.DateTimeFormat.MonthNames[date.Month-1]; groupMonth.RowLayoutGroupInfo.OriginX = dayCount; groupMonth.RowLayoutGroupInfo.OriginY = 0; groupMonth.RowLayoutGroupInfo.SpanX = this.servicePlan.OpenInfo.OpenRange.Contains( endOfMOnth ) ? DateTime.DaysInMonth( date.Year, date.Month ) : this.servicePlan.OpenInfo.OpenRange.To.Day; groupMonth.RowLayoutGroupInfo.SpanY = 6; } // week of year group if ( date.DayOfWeek == cultureInfo.DateTimeFormat.FirstDayOfWeek ) { int weekOfYear = cultureInfo.DateTimeFormat.Calendar.GetWeekOfYear( date, cultureInfo.DateTimeFormat.CalendarWeekRule, cultureInfo.DateTimeFormat.FirstDayOfWeek ); int weekSpanX = this.servicePlan.OpenInfo.OpenRange.Contains( date.AddDays( 6 ) ) ? 7 : ( this.servicePlan.OpenInfo.OpenRange.To.Date - date.Date ).Days; key = string.Format( "GroupWeekNum{0}", weekOfYear ); if ( !band0.Groups.Exists( key ) ) { // -> week number groupWeekNum = band0.Groups.Add( key ); groupWeekNum.Header.Caption = weekOfYear.ToString(); groupWeekNum.RowLayoutGroupInfo.OriginX = dayCount; groupWeekNum.RowLayoutGroupInfo.OriginY = 2; groupWeekNum.RowLayoutGroupInfo.SpanX = weekSpanX; groupWeekNum.RowLayoutGroupInfo.SpanY = 2; groupWeekNum.RowLayoutGroupInfo.ParentGroup = groupMonth; // -> day of month for week number groupWeekDay = band0.Groups.Add( string.Format( "GroupWeekDay{0}", weekOfYear ) ); groupWeekDay.Header.Caption = date.Day.ToString(); groupWeekDay.RowLayoutGroupInfo.OriginX = dayCount; groupWeekDay.RowLayoutGroupInfo.OriginY = 4; groupWeekDay.RowLayoutGroupInfo.SpanX = weekSpanX; groupWeekDay.RowLayoutGroupInfo.SpanY = 2; groupWeekDay.RowLayoutGroupInfo.ParentGroup = groupMonth; } } // assign Band 0 column col = band0.Columns[colKey]; col.Width = printOptions.FitToColWidth; col.MinWidth = printOptions.FitToColWidth; col.RowLayoutColumnInfo.ParentGroup = groupWeekNum; // assign Band 1 column col = band1.Columns[colKey]; col.Width = printOptions.FitToColWidth; col.MinWidth = printOptions.FitToColWidth; col.RowLayoutColumnInfo.ParentGroup = groupWeekNum; dayCount++; } // disable label sizing band0.Layout.Override.AllowRowLayoutLabelSizing = RowLayoutSizing.None; } catch ( Exception x ) { Logger.Error( x, false ); }
Thank you for any help.
Regards
Markus
Hello Mike,
I have fixed it: I did not set the Indentation = 0 for the root band, just for the child band. In another grid without GroupLayout, this was not necessary.
This problem was also discussed here: http://ko.infragistics.com/community/forums/t/69377.aspx
Everything works fine now.
we have evaluated the control type far ago for our employee scheduling task view. And this we talking about hereshould be a printout in compact layout to show yearly planned vacations and something like this, without opening the schedule view before.
But I have found a solution. I have modified your sample und attached it to this post. For me, the key for having overlapping week-groups was NOT to define the parent-group for the week-groups. All groups are just arranged by the coordinates and all columns are added to their month-group, not to the week-group.
In my work project I have one last problem, you maybe can give me a tip: On the left side of the grid (left to the employee names) you see some emty space. This space belongs to the grid, because if I set some grid back color, the color of this space changes. If I turn row selectors on, the empty space remains (see attached picture).
I could not figure out where is this coming from. Remeber: I add the grid to the preview-dlg controls container as hidden component, because I don't have a hosting form. Otherwise nothing is printed to the preview. Has this any (bad) influence?
Thank you for your help.
Hi Markus,
I just wanted to let you know that I am actively looking into this. I tried solving the overlapping issue, and was not able to come up with a good solution -- a group is not intended to span multiple parent groups.
RowLayouts are not normally configured in code. Although the properties are exposed, the intention is for the work to be done in the designer.
Are you able to use a control other than the grid for this project? I believe that the spreadsheet, schedule, or ganttview might be a better control to display data in this way. Please look into these controls and let me know your thoughts.
Hello again,
I still having some problems arranging the header groups. I guess I have figured out what the problem could be. If the week-groups overlapping the month borders, and week-groups and columns both have the current month-group as parent, it leads to some visually disalignement at the end of 'march' (see attached pic). The disalignement are two columns, one overlapping week 5 and one averlapping week 9.
In your sample you dont't solve this problem, because you just have used one month and you have cut the weeks.
Do you have a solution for this problem?
I have tried define one more header-group, which spans overall other groups and acts as parent-group for all others. But I could not assign the columns in a way that all groups are sized ok. What is about this approach?
Regards, Markus
I have done some work on the layout and so on. Visually I have two last problem. First: The last column of the last week (see attached picture) is somewhat streched for group headers and band 0 columns. Band 1 columns are not. Second: There is some empty space on the left of the grid. I could not found the reason for this. This area is affected by the grid.appearance.backcolor. I use the print document with defaults, ecept border.
Conceptually I'm not sure if I'm using the group headers correctly. If I have two bands, do I need to define the header groups for every band and assigning the band0-columns to the band0-groups and the band1-columns to the band1-groups.
If I just set properties as in your sample, my grid looks complete "unaligned". In the documentation I could not find a more complex sample with multiband and multirow-header.
Best regards