To use a derived GridModelDataBinder requires you to derive the grid and the gridmodel as well. Below are some code snippets.
In order for the GridGroupingControl to handle grouping, it must have access to all the data. It can only group what it can access.
public class DerDataBoundGrid : GridDataBoundGrid
{
DerDataBoundGridModel gridModel;
public DerDataBoundGrid(): base(new DerDataBoundGridModel())
{
gridModel = (DerDataBoundGridModel) Model;
}
protected override void OnPrepareViewStyleInfo(GridPrepareViewStyleInfoEventArgs e)
{
base.OnPrepareViewStyleInfo (e);
}
protected override GridModelDataBinder CreateBinder()
{
return new DerModelDataBinder(gridModel);
}
}
public class DerModelDataBinder : GridModelDataBinder
{
DerDataBoundGridModel gridModel;
public DerModelDataBinder(DerDataBoundGridModel model) : base(model)
{
this.gridModel = model;
}
CurrencyManager listManager = null;
CurrencyManager ListManager
{
get
{
if (this.listManager == null && this.BindingContext != null && this.DataSource != null)
return (CurrencyManager) this.BindingContext[this.DataSource, this.DataMember];
return this.listManager;
}
}
protected override void QueryCellInfo(GridQueryCellInfoEventArgs e)
{
base.QueryCellInfo (e);
}
protected override void SaveCellInfo(GridSaveCellInfoEventArgs e)
{
base.SaveCellInfo (e);
}
}
public class DerDataBoundGridModel : GridDataBoundGridModel
{
public DerDataBoundGridModel()
{
}
protected override void OnQueryCellInfo(GridQueryCellInfoEventArgs e)
{
base.OnQueryCellInfo (e);
}
protected override void OnSaveCellInfo(GridSaveCellInfoEventArgs e)
{
base.OnSaveCellInfo (e);
}
}