I''m trying to create a Grouping Grid.
Table is single dimensioned.
I have created a summary row, and
I want the summary row to appear as
a GroupCaptionSummary.
My summary row works fine when I group by a column. It also works fine for TopLevel by
setting TopLevelGroupOptions.ShowSummaries = true.
Basically the look I want is that the summaries appear before the data rows.
So, I''m trying to set TopLevelGroupOptions.ShowCaptionSummaryCells = true, with TopLevelGroupOptions.CaptionSummaryRow = "MySumRow"
When I try this setup, I get ArgumentOutOfRangeExcecption.
Looks like when trying to create a SummaryCell
the grid tries to find the grouped colum at the group Level.
From GridTable.cs at line 1686:
if (g != null && g.GroupOptions.ShowCaptionSummaryCells)
{
e.TableCellType = GridTableCellType.GroupCaptionSummaryCell;
e.GroupedColumn = this.TableDescriptor.GroupedColumns[displayElement.GroupLevel-1];
Since this is a top level, GroupLevel will be 0.
This will also fail if there is currently no grouped columns.
Is there a workaround for this? I want to show a table summary row at the top of the grid.
TopLevel ShowCaptionSummaryCells doesn''t work.
This happens with just about any of the grouping grid samples supplied with the suite.
Out current production release is build around 2.0.5.1 and I can''t really change that right now to get this working. So even if the workaround is to subclass GridTable, I''m willing to do so.
Just looking for some guidance from Stefan or Clay.
Adam Miller
UBS
AD
Administrator
Syncfusion Team
October 1, 2004 05:34 PM UTC
Hi Adam,
sorry - Only workaround with the existing version is to set TopLevelGroupOptions.ShowCaptionSummaryCells = false. Then this code won''t get hit. Otherwise there is no way to avoid that line being hit ...
If you want you could also modify that one line. There needs to be an
if (displayElement.GroupLevel > 0)
line before accessing
e.GroupedColumn = this.TableDescriptor.GroupedColumns[displayElement.GroupLevel-1];
Stefan
AM
Adam Miller
October 1, 2004 06:42 PM UTC
Is this fixed in the 2.1.0.9 release ?
AM
Adam Miller
October 1, 2004 06:52 PM UTC
Is there any other way to accomplish what I want?
It would be real nice to have the SummaryRow for the entire table to appear at the top, under the row headers.
Is there an override that would allow translating row positions that would put the summary row as row #1 instead of the last row ?
AD
Administrator
Syncfusion Team
October 1, 2004 07:02 PM UTC
No, I only fixed it last week when I worked on some other sample and noticed the issue for the first time.
Actually I think one thing you could do would be to set TopLevelGroupOptions.ShowCaptionSummaryCells and then manually handle groupingGrid.QueryCellStyleInfo and groupingGrid.TableModel.QueryCoveredRange events.
In QueryCoveredRange you can set e.Handled = true then the default covering for the caption bar will not happen.
This is the code from within GridTable that you could copy paste:
if (e.RowIndex < thisTable.DisplayElements.Count)
{
Element el = thisTable.DisplayElements[e.RowIndex];
switch (el.Kind)
{
case DisplayElementKind.Caption:
{
int maxCaptionColCount = Math.Max(this.GetColumnIndentCount(), TableDescriptor.GetColCount()-1);
int startCol = el.GroupLevel+1;
IGridGroupOptionsSource g = el.ParentGroup as IGridGroupOptionsSource;
if (g != null && !g.GroupOptions.ShowCaptionPlusMinus)
{
startCol--;
}
int d = (ParentTableDescriptor.Relations.NestedCount > 0) ? 1 : 0;
if (!((GridTable) el.ParentTable).TableOptions.ShowRecordPlusMinus)
d = 0;
if (e.ColIndex >= startCol && e.ColIndex <= maxCaptionColCount)
{
if (g == null || !g.GroupOptions.ShowCaptionSummaryCells)
{
e.Range = GridRangeInfo.Cells(e.RowIndex, startCol, e.RowIndex, maxCaptionColCount);
e.Handled = true;
}
else
{
e.Range = GridRangeInfo.Cell(e.RowIndex, e.ColIndex);
if (e.Range.Left <= GetColumnIndentCount())
{
e.Range = e.Range.UnionRange(GridRangeInfo.Cells(e.Range.Top, el.GroupLevel+1+d, e.Range.Bottom, GetColumnIndentCount()));
e.Handled = true;
}
}
}
else if (e.ColIndex == el.GroupLevel)
{
e.Range = GridRangeInfo.Cell(e.RowIndex, e.ColIndex);
e.Handled = true; // PlusMinus
}
else if (e.ColIndex > maxCaptionColCount)
{
e.Range = GridRangeInfo.Cell(e.RowIndex, e.ColIndex);
e.Handled = true;
}
break;
}
Next step would be to handle QueryCellStyleInfo for those cells at the top and manually set e.Style.CellValue.
Stefan
AM
Adam Miller
October 1, 2004 07:25 PM UTC
Where does that code snippet go?
In the QueryCellStyleInfo handler ?