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.
Unfortunately, activation email could not send to your email. Please try again.

Merging cells based on grouping

Thread ID:

Created:

Updated:

Platform:

Replies:

19501 Sep 28,2004 02:54 AM Jun 5,2011 03:50 PM Windows Forms 5
loading
Tags: Grouping
Ronen Lev
Asked On September 28, 2004 02:54 AM

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?

Administrator [Syncfusion]
Replied On 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

Nihar Ranjan Dalai
Replied On June 2, 2011 06:46 AM

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

Thanks.


Arulraj A [Syncfusion]
Replied On 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



Nihar Ranjan Dalai
Replied On 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.


Arulraj A [Syncfusion]
Replied On 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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;