Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
165
Custom Merging of cells
posted

Hi group

 I have a requirement of merging cells according to my own custom logic which is driven by data.I checked the infragistics documentation.I found below.But certain things are not clear in the below example For Eg,i am not clear on how the function ShouldCellsBeMerged should be called in my code and how to set MergedCell style only on some columns..does anyone have a better/detailed working example for this ?

 Thanks

Anusha

 

You can have your own custom logic for merging cells by implementing IMergedCellEvaluator interface and assigning an instance of it to the MergedCellEvaluator property of the UltraGridColumn object. The following code implements IMergedCellEvaluator on CustomMergedCellEvaluator class and sets it on the ShippedDate column in the InitializeLayout event handler of an

WinGrid is a hierarchical data bound grid control. It has full support for displaying hierarchical data provided by any data source that implements IList or ITypedList.

Toolbox Item: UltraGrid

Namespace: Infragistics.Win.UltraWinGrid

',event)">WinGrid
™.

public class CustomMergedCellEvaluator:
Infragistics.Win.UltraWinGrid.IMergedCellEvaluator
{
public CustomMergedCellEvaluator()
{

}

public bool ShouldCellsBeMerged(UltraGridRow row1,
  UltraGridRow row2, UltraGridColumn column)
{
// Test to make sure the Type is not DBNull since we allow the ShippedDate to be null
if (row1.GetCellValue(column).GetType().ToString() != "System.DBNull" && row2.GetCellValue(column).GetType().ToString() != "System.DBNull")
{
DateTime date1 = (DateTime)row1.GetCellValue(column);
DateTime date2 = (DateTime)row2.GetCellValue(column);
// Merge cells according to the date portions of the underlying DateTime cell
// values, ignoring any time portion. For example, "1/1/2004 10:30 AM" will be
//  merged with "1/1/2004 1:15 AM" since the dates are the same.

return date1.Date == date2.Date;
}
else
return false;
}
}

private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
{
// Set the MergedCellStyle property to enable the merged cell functionality.
// MergedCellStyle also specifies which columns will merge their cells.

e.Layout.Override.MergedCellStyle = MergedCellStyle.Always;

// MergedCellEvaluator property can be used to specify custom logic for
// merging cells.

e.Layout.Bands[0].Columns["ShippedDate"].MergedCellEvaluator = new CustomMergedCellEvaluator();
}

 

Parents
No Data
Reply
  • 85
    posted

    HEllo

    I implemented the CustomMergedCellEvaluator

    however the ShouldCellsBeMerged is not being called

    I tried to call the method on the initialize row event but how to get the next row to pass it to this method?

Children