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

How to Merge Columns in Grid Grouping control

Hi,

I have to merge multiple columns and display a single header text for the merged columns in grid grouping control. Is it possible???.
Can you guys suggest an approach.

4 Replies

RA Rajagopal Syncfusion Team September 6, 2007 05:36 PM UTC

Hi Venkat,

Thanks for your interest in Syncfusion Products.

You can merge columns in grid and make it behave like a cell single cell with a headertext by handling the TableModel.QueryCoveredRange event of the GridGroupingControl. Below is the code snippet.

void TableModel_QueryCoveredRange(object sender, GridQueryCoveredRangeEventArgs e)
{
Element el = this.gridGroupingControl1.TableModel.GetDisplayElementAt(e.RowIndex);
if (el != null && el.Kind == DisplayElementKind.ColumnHeader)
{
int lastCol = this.gridGroupingControl1.TableDescriptor.VisibleColumns.Count;
e.Range = GridRangeInfo.Cells(e.RowIndex, 1, e.RowIndex, lastCol);
e.Handled = true;
}
}

Here is a sample demonstrating this
http://websamples.syncfusion.com/samples/Grid.Windows/F68023/main.htm

Let me know if you have any other questions.

Regards,
Rajagopal


VA Venkat Akella September 10, 2007 02:07 PM UTC



>Hi Venkat,

Thanks for your interest in Syncfusion Products.

You can merge columns in grid and make it behave like a cell single cell with a headertext by handling the TableModel.QueryCoveredRange event of the GridGroupingControl. Below is the code snippet.

void TableModel_QueryCoveredRange(object sender, GridQueryCoveredRangeEventArgs e)
{
Element el = this.gridGroupingControl1.TableModel.GetDisplayElementAt(e.RowIndex);
if (el != null && el.Kind == DisplayElementKind.ColumnHeader)
{
int lastCol = this.gridGroupingControl1.TableDescriptor.VisibleColumns.Count;
e.Range = GridRangeInfo.Cells(e.RowIndex, 1, e.RowIndex, lastCol);
e.Handled = true;
}
}

Here is a sample demonstrating this
http://websamples.syncfusion.com/samples/Grid.Windows/F68023/main.htm

Let me know if you have any other questions.

Regards,
Rajagopal


thank you, if i want to merge from the middle columnsheaders of the grid then?


RA Rajagopal Syncfusion Team September 10, 2007 06:31 PM UTC

Hi Venkat,

In the TableModel.QueryCoveredRange event of the GridGroupingControl, you need to specify the range of the cells that you want it merged/covered. To cover the column headers from any column index in the middle, then you need to pass the column index from which the cells should be covered and the column index untill which the columns will be covered. Please refer the below sample that shows the column headers being covered from middle.

http://websamples.syncfusion.com/samples/Grid.Windows/F68023/main.htm

Let me know if you have any other questions.

Regards,
Rajagopal


CN canh nguyen May 18, 2010 04:19 AM UTC

How to merge cell in gridGroupingControl?,please help me.

Thank you very much.

Loader.
Live Chat Icon For mobile
Up arrow icon