// GroupingEngineFactory provides a modified GridChildTable that adds an extra section
GridEngineFactory.Factory = new GroupingEngineFactory();
this.groupingGrid1.QueryCellStyleInfo += new GridTableCellStyleInfoEventHandler(groupingGrid1_QueryCellStyleInfo);
this.groupingGrid1.TableModel.QueryCoveredRange += new Syncfusion.Windows.Forms.Grid.GridQueryCoveredRangeEventHandler(TableModel_QueryCoveredRange);
// QueryCoveredRange might or might not be of use for you ...
private void TableModel_QueryCoveredRange(object sender, Syncfusion.Windows.Forms.Grid.GridQueryCoveredRangeEventArgs e)
{
GridTableModel tm = sender as GridTableModel;
Element el = tm.Table.DisplayElements[e.RowIndex];
if (el is ColumnHeaderRow)
{
GridTableCellStyleInfo style = tm[e.RowIndex, e.ColIndex];
//if (style.TableCellIdentity.Column.Name == "CustomerID"
// || style.TableCellIdentity.Column.Name == "CompanyName")
if (e.ColIndex >= 3 && e.ColIndex <= 4)
e.Range = GridRangeInfo.Cells(e.RowIndex, 3, e.RowIndex, 4);
e.Handled = true;
}
}
// groupingGrid1_QueryCellStyleInfo lets you specify the text to be displayed in the additional headers
private void groupingGrid1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
e.Style.CellTipText = e.TableCellIdentity.Info;
if (e.TableCellIdentity.DisplayElement is ExtraSection)
{
e.Style.CellValue = "Extra";
}
}
public class GroupingEngineFactory : GridEngineFactoryBase
{
public override GridEngine CreateEngine()
{
return new GroupingEngine();
}
}
public class GroupingEngine : GridEngine
{
public override ChildTable CreateChildTable(Element parent)
{
return new GroupingChildTable(parent);
}
}
public class ExtraSection : EmptySection
{
public ExtraSection(Group parent)
: base(parent)
{
}
public override DisplayElementKind Kind
{
get { return DisplayElementKind.None; }
}
public override int GetElementCount()
{
return 1;
}
public override int GetVisibleCount()
{
return 1;
}
public override double GetYAmountCount()
{
return 40;
}
}
public class GroupingChildTable : GridChildTable
{
public GroupingChildTable(Element parent)
: base(parent)
{
}
protected override void OnInitializeSections(bool hasRecords, SortColumnDescriptorCollection fields)
{
base.OnInitializeSections(hasRecords, fields);
EndInit();
if (this.IsTopLevelGroup)
{
// Search for Detailssection
for (int n = 0; n < Sections.Count; n++)
{
Section s = this.Sections[n];
if (s is DetailsSection)
{
// Insert before Details
InvalidateCounter();
this.Sections.Insert(n, new ExtraSection(this));
break;
}
}
}
}
public override bool IsChildVisible(Element el)
{
if (this.IsTopLevelGroup && el is ExtraSection)
{
return true;
}
else
return base.IsChildVisible(el);
}
}
Stefan