Hi,
I want to merge cells in my grid. I have gone through VirtualMergeCells sample and have done in a similar way. But the issue is, OnQueryCanMergeCells is not getting called for all columns. It is just being called for first column. So only the first colum,n is getting merged and in all other columns, data is repeated. Briefly these are my grid settings:
Cols.FrozenCount = 1;
BaseStylesMap["Header"].StyleInfo.Trimming = StringTrimming.EllipsisCharacter;
GridStyleInfo standardStyle = BaseStylesMap["Standard"].StyleInfo;
standardStyle.MergeCell = GridMergeCellDirection.RowsInColumn;
GridStyleInfo rowHeaderStyle = BaseStylesMap["Row Header"].StyleInfo;
rowHeaderStyle.MergeCell = GridMergeCellDirection.RowsInColumn;
BaseStylesMap.Modified = false;
// Other options
Model.Options.MergeCellsMode = GridMergeCellsMode.BeforeDisplayCalculation | GridMergeCellsMode.MergeRowsInColumn;
Model.Options.ExcelLikeCurrentCell = false;
Model.Options.ExcelLikeSelectionFrame = false;
Model.Options.ResizeRowsBehavior = GridResizeCellsBehavior.ResizeSingle;
Model.Options.ControllerOptions = GridControllerOptions.ResizeCells;
CellModels.Add("details", new RevisionDetailsCellModel(Model));
protected override void OnQueryCanMergeCells(GridQueryCanMergeCellsEventArgs e)
{
base.OnQueryCanMergeCells(e);
if (e.Handled || RowCount == 0)
return;
GridStyleInfoIdentity identity1 = e.Style1.CellIdentity;
GridStyleInfoIdentity identity2 = e.Style2.CellIdentity;
if (identity1.ColIndex <= 0)
return;
e.Handled = true;
e.Result = false;
if (identity1.ColIndex <= 3 &&
identity1.RowIndex > 0 &&
identity2.RowIndex <= RowCount)
{
e.Result = CanMergeCells(identity1.RowIndex, identity2.RowIndex);
}
}
There are totally four columns and we try to merge the values of first three columns. The above method is not getting call for column index > 1. Kindly let me know how to resolve this.
Syncfuison version: 3.201.1.0
Thanks
Kiran
FA
Faltu
July 15, 2008 12:07 PM UTC
Hi,
Can someone kindly respond? Thanks.
Regards
Kiran
FA
Faltu
July 15, 2008 03:38 PM UTC
Hi,
QueryMergeCells is not working as expected. The method OnQueryCanMergCells is not getting called for all rows in a single column. Also, it is not fired for all columns. Kindly explain the logic behind this. Thanks.
Regards
Kiran
JJ
Jisha Joy
Syncfusion Team
July 16, 2008 10:43 AM UTC
Hi Kiran,
Please use the following code snippets and let me know if this helps:
protected override void OnQueryCanMergeCells(GridQueryCanMergeCellsEventArgs e)
{
base.OnQueryCanMergeCells (e);
if (!e.Handled)
{
GridStyleInfoIdentity id1 = e.Style1.CellIdentity;
GridStyleInfoIdentity id2 = e.Style2.CellIdentity;
if (id1.ColIndex <= 3)
{
e.Result = CanMergeCells(e.Style1, e.Style2);
e.Handled = true;
}
}
}
public bool CanMergeCells(GridStyleInfo style1, GridStyleInfo style2)
{
GridStyleInfoIdentity id1 = style1.CellIdentity;
GridStyleInfoIdentity id2 = style2.CellIdentity;
if (id1.RowIndex < 1 || id2.RowIndex < 1)
return false;
return style1.Text != "" && style1.Text == style2.Text;
}
We appreciate your interest in Syncfusion Products.
Regards,
Jisha