I have my grid sorted on the the first 4 columns and I would like to merge the cells only within a logical group according to the sort. An example with help illustrate.
Each time the first column changes all of the next columns should not merge and display.
IF the second column changes then all subsequent columns should display
For this data
I want it to look like this:
But I get this:
Hi,
You can achieve this by implementing a custom merged cell evalutor for the columns you want to alter the merged behavior.
To get you started you can create a class that implements the IMergedCellEvaluator interface and assigning it to a column:
class CustomCellMerger : IMergedCellEvaluator { public bool ShouldCellsBeMerged(UltraGridRow row1, UltraGridRow row2, UltraGridColumn column) { if (!row1.Cells["Symbol"].IsMergedWith(row2.Cells["Symbol"])) { return false; }
return true; } }
Back at the grid set the column to use this evaluator:
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e){ e.Layout.Bands[0].Columns["Expiration"].MergedCellEvaluator = new CustomCellMerger();}
Continue this out for the other columns you want to modify the merged cell behavior for and you can implement the merging behavior you were after.