We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Merging cells based on grouping

Hi, I have a table which is grouped (using GridGroupingControl), each value in the grouping column is associated with an image. I would like to merge all of the cells in one column which belong to the same group and display the image associated with the group. Is there a way to accomplish this?

5 Replies

AD Administrator Syncfusion Team September 28, 2004 12:30 PM

Hi Ronen, you can handle the TableModel.QueryCoveredRange and TableControlPrepareViewStyleInfo event. Example: private void groupingGrid1_TableControlPrepareViewStyleInfo(object sender, GridTableControlPrepareViewStyleInfoEventArgs e) { GridTableCellStyleInfo style = (GridTableCellStyleInfo) e.Inner.Style; RecordRow recordRow = style.TableCellIdentity.DisplayElement as RecordRow; if (recordRow != null) { Record r = style.TableCellIdentity.DisplayElement.ParentRecord; //int recordIndex = r.ParentTable.Records.IndexOf(r); int rowInRecordIndex = r.RecordRows.IndexOf(recordRow); GridColumnDescriptor column = style.TableCellIdentity.Column; if (column != null) { switch (column.Name) { case "CompanyName": { e.Inner.Style.Interior = new Syncfusion.Drawing.BrushInfo(Syncfusion.Drawing.GradientStyle.Vertical, Color.White, Color.Orange); e.Inner.Style.Text = rowInRecordIndex.ToString(); break; } case "ContactName": { e.Inner.Style.Interior = new Syncfusion.Drawing.BrushInfo(Syncfusion.Drawing.GradientStyle.Vertical, Color.White, Color.Orange); break; } } } } } private void TableModel_QueryCoveredRange(object sender, GridQueryCoveredRangeEventArgs e) { GridTableModel model = (GridTableModel) sender; GridTable thisTable = model.Table; if (e.RowIndex < thisTable.DisplayElements.Count) { Element el = thisTable.DisplayElements[e.RowIndex]; if (el is RecordRow && el.ParentGroup != null) { GridTableCellStyleInfo style = model[e.RowIndex, e.ColIndex]; if (style.TableCellIdentity.Column != null && style.TableCellIdentity.Column.Name == "CompanyName") { Group group = el.ParentGroup; if (group != null && !group.IsTopLevelGroup) { int tablePos = thisTable.DisplayElements.IndexOf(group); int firstRow = tablePos+1; int lastRow = tablePos+group.GetVisibleCount()-1; e.Range = GridRangeInfo.Cells(firstRow, e.ColIndex, lastRow, e.ColIndex); e.Handled = true; } } } } } private void TableModel_QueryBanneredRange(object sender, GridQueryBanneredRangeEventArgs e) { GridTableModel model = (GridTableModel) sender; GridTable thisTable = model.Table; if (e.RowIndex < thisTable.DisplayElements.Count) { Element el = thisTable.DisplayElements[e.RowIndex]; if (el is RecordRow && el.ParentGroup != null) { GridTableCellStyleInfo style = model[e.RowIndex, e.ColIndex]; if (style.TableCellIdentity.Column != null && style.TableCellIdentity.Column.Name == "ContactName") { Group group = el.ParentGroup; if (group != null && !group.IsTopLevelGroup) { int tablePos = thisTable.DisplayElements.IndexOf(group); int firstRow = tablePos+1; int lastRow = tablePos+group.GetVisibleCount()-1; e.Range = GridRangeInfo.Cells(firstRow, e.ColIndex, lastRow, e.ColIndex); e.Handled = true; } } } } } I attached a modified GroupCustomers project. Make sure the xml file can be found that is loaded in the form ctor. Stefan GroupCustomers_Covered_and_Bannered_Ranges_5304.zip


NR Nihar Ranjan Dalai June 2, 2011 06:46 AM

Unable to download the project attached. Could you please point me to an appropriate link for download?

Thanks.



AA Arulraj A Syncfusion Team June 3, 2011 12:06 AM

Hi Nihar,

Thanks for your interest in Syncfusion products.

Please make us of the following link to download the above sample ”groupcustomers_covered_and_bannered_ranges_5304”.

Sample link:
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=groupcustomers_covered_and_bannered_ranges_5304-1285587679.zip

Please let us know if you have any further concerns.

Regards,
Arulraj.A




NR Nihar Ranjan Dalai June 3, 2011 08:22 AM

Hi,

Could you please also provide the GDBData.xml file that is required to run the sample? It is not present in the zip that you have shared.

Thanks and regards,
Nihar.



AA Arulraj A Syncfusion Team June 5, 2011 03:50 PM

Hi Nihar,

Thanks for the update.

Please download the GDBDdata.xml file from the following link.

'http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=GDBDdata-1202303176.zip

Let us know if you have any further concerns.

Regards,
Arulraj A


Loader.
Live Chat Icon For mobile
Up arrow icon