Hi everyone,
I would like a help with a grid i'm trying to implement.
I'm trying to create a grid with three columns, one for month, one for quantity and other for percentage of a product. The rows will describe the months, the quantity and percentage of each month. But i wanted to place a header, with a row with the description of the column and a upper row header with the name of the product with "merged" cell that would take the space of all the columns.
How can i make a line with more than one row? And how can i merge the descriptions of a header?
JJ
Jisha Joy
Syncfusion Team
November 20, 2008 05:25 AM UTC
Hi Daniel,
We appreciate your interest in Syncfusion Products.
Additional row headers can be added below the existing header by setting the Model.Rows.HeaderCount. Model.Rows.FrozenCount is set so that the additional headers don’t scroll.
int extraRowHeaders = 2;
int extraColHeaders = 1;
this.gridDataBoundGrid1.Model.Rows.HeaderCount = extraRowHeaders; this.gridDataBoundGrid1.Model.Rows.FrozenCount = extraRowHeaders;
this.gridDataBoundGrid1.Model.Cols.HeaderCount = extraColHeaders;
this.gridDataBoundGrid1.Model.Cols.FrozenCount = extraColHeaders;
The Model.CoveredRanges is used to cover some cells and to show them as a group.
this.gridDataBoundGrid1.Model.CoveredRanges.Add(GridRangeInfo.Cells(1, 2, 1, 3));
this.gridDataBoundGrid1[1, 2].Text = "Covered Cell - Group One";
Please refer the following browser sample for more details:
..\\My Documents\Syncfusion\EssentialStudio\{version}\Windows\Grid.Windows\Samples\2.0\DataBound\GDBGMultiHeader
This sample will show you how to have multiple row and / or column headers in your GridDataBoundGrid as well as additional unbound rows or columns.
Please try this and let me know if this helps.
Regards,
Jisha
DS
Daniel Santos de Carvalho
November 25, 2008 05:57 PM UTC
Hi Jisha,
Actually, i'm trying to make a 4 rows header, and used the code below from based on the example...
int extraRowHeaders = 3;
int extraColHeaders = 1;
this.gridDataBoundGrid1.Model.Rows.HeaderCount = extraRowHeaders;
this.gridDataBoundGrid1.Model.Rows.FrozenCount = extraRowHeaders;
this.gridDataBoundGrid1.Model.Cols.HeaderCount = extraColHeaders;
this.gridDataBoundGrid1.Model.Cols.FrozenCount = extraColHeaders;
I wrote the code as the example and worked fine for two rows header, but i have difficult accessing "text property" of cells of the header with more rows (like "rowindex" 2 and 3):
this.gridDataBoundGrid1[2, 2].Text = "Covered Cell";
this.gridDataBoundGrid1[3, 2].Text = "Covered Cell";
The code above give indexoutofbounds exception..
JJ
Jisha Joy
Syncfusion Team
November 26, 2008 09:57 AM UTC
Hi Daniel,
Please try to handle QueryCellInfo event and set the text there by checking Rowindex and ColumnIndex. Please see the code:
this.gridDataBoundGrid1.Model.QueryCellInfo += new GridQueryCellInfoEventHandler(Model_QueryCellInfo);
void Model_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
if (e.RowIndex == 2 && e.ColIndex == 2)
e.Style.Text = "Covered Cell ";
}
Regards,
Jisha
DS
Daniel Santos de Carvalho
November 26, 2008 04:29 PM UTC
Ok, it worked perfectly
Thanks a lot, Jisha!