We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

multiple header problem

Hello

I am trying to group multiple columns under a single column in grid. suppose I have two columns 'city' and 'country' and I made another column named 'address' as their header, by merging cells. so address column header have two children column headers, city and country.
now problem is whenever I click on the address column it just selects left most child column. I want to select all the columns that lies under the main column.

similarly when I click on any of child column header, it does not select its respective column, even though i have tried to set its cellType, Header and ColumnheaderCell.

4 Replies

HA haneefm Syncfusion Team April 5, 2007 06:55 PM UTC

Hi Touqeer,

This can be achieved by handling the CellClick event of the grid and use Model.Selection property to add the selection in a grid. The following is the code snippet.

private void gridDataBoundGrid1_CellClick(object sender, GridCellClickEventArgs e)
{
if( e.RowIndex == 0 )
{
e.Cancel = true;
GridDataBoundGrid grid = sender as GridDataBoundGrid;
grid.Model.Selections.Clear(true);
GridRangeInfo info = grid.Model.CoveredRanges.FindRange(e.RowIndex,e.ColIndex);
grid.Model.Selections.Add(GridRangeInfo.Cols(info.Left,info.Right));
}
if( e.RowIndex == 1 )
{
e.Cancel = true;
GridDataBoundGrid grid = sender as GridDataBoundGrid;
grid.Model.Selections.Clear(true);
grid.Model.Selections.Add(GridRangeInfo.Cells(1,e.ColIndex,grid.Model.RowCount,e.ColIndex ));
}
}

Please refer to the attached sample for implementation.
GDBGMultiHeader.zip

Best regards,
Haneef


TA Touqeer Ahmed Ahson April 9, 2007 05:36 AM UTC

Hi Haneef
it is working, thanks for help...
but there is a problem in it.
sub column header i.e first name and last name is not dragged properly as main column headers....


HA haneefm Syncfusion Team April 9, 2007 11:07 AM UTC

Hi Touqeer,

One way you can do this by derving the GridDragSelectMouseController class and overide HitTest. There you can adjust the return value so it is GridHitTestContext.SelectedRange if you are over row 1(sub column header) and row 0 (covered column header). You would have to remove the old controller and register your derived one with code like:

IMouseController controller = this.gridDataBoundGrid1.MouseControllerDispatcher.Find("DragSelect");
this.gridDataBoundGrid1.MouseControllerDispatcher.Remove(controller);
this.gridDataBoundGrid1.MouseControllerDispatcher.Add(new MyGridDragSelectMouseController(this.gridDataBoundGrid1));

Best regards,
Haneef


TA Touqeer Ahmed Ahson April 11, 2007 12:40 PM UTC

Hi Haneef,
I would be greatful if you provide me example code, I have tried it but could not get it right.
so please plz plz help........
Regards,
Touqeer

Loader.
Live Chat Icon For mobile
Up arrow icon