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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridGroupingControl - Combining column headers and moving them(columns) together

Thread ID:

Created:

Updated:

Platform:

Replies:

35632 Oct 5,2005 03:28 PM UTC Oct 7,2005 04:26 PM UTC Windows Forms 6
loading
Tags: GridControl
Badri Rajani Kanth
Asked On October 5, 2005 03:28 PM UTC

Hi All, I am displaying data in a GridGroupingControl. I have requirements to 1. Combine few column headers and give them combined caption/header. 2. When user try to move those columns, they should move together. As if they are one column. 3. User should not be able to move some other column into these combined columns. He can only place on either sides of combined columns. But not in between. I am able to achive requirement 1. But having problems for 2 and 3. Can any body help me? Code sample used for requirement 1: =================================== private void TableModel_QueryCoveredRange(object sender, GridQueryCoveredRangeEventArgs e) { GridTableModel tm = sender as GridTableModel; Element el = tm.Table.DisplayElements[e.RowIndex]; if (el is CaptionRow) { GridTableCellStyleInfo style = tm[e.RowIndex, e.ColIndex]; int maxCaptionColCount = Math.Max(tm.Table.TableDescriptor.GetColumnIndentCount(), tm.Table.TableDescriptor.GetColCount()-1); int startCol = el.GroupLevel+1; maxCaptionColCount = Math.Min(5+1, maxCaptionColCount); IGridGroupOptionsSource g = el.ParentGroup as IGridGroupOptionsSource; if (g != null && !g.GroupOptions.ShowCaptionPlusMinus) { startCol--; } int d = (el.ParentTable.RelatedTables.Count > 0) ? 1 : 0; if (!((GridTable) el.ParentTable).TableOptions.ShowRecordPlusMinus) d = 0; if (e.ColIndex >= startCol && e.ColIndex <= maxCaptionColCount) { e.Range = GridRangeInfo.Cells(e.RowIndex, startCol, e.RowIndex, maxCaptionColCount); e.Handled = true; } } if (el is ColumnHeaderRow) { GridTableCellStyleInfo style = tm[e.RowIndex, e.ColIndex]; if (style.TableCellIdentity.Column.Name == "ContactId" || style.TableCellIdentity.Column.Name == "ClientId" || style.TableCellIdentity.Column.Name == "ContactPriority" || style.TableCellIdentity.Column.Name == "FullName" ) { int startCol = el.GroupLevel+1; int colIndex = e.ColIndex; if (style.TableCellIdentity.Column.Name == "ClientId") colIndex--; if (style.TableCellIdentity.Column.Name == "ContactPriority") colIndex = colIndex -2 ; if (style.TableCellIdentity.Column.Name == "FullName") colIndex = colIndex -3 ; e.Range = GridRangeInfo.Cells(e.RowIndex, colIndex, e.RowIndex, colIndex + 3); e.Handled = true; } } }

Administrator [Syncfusion]
Replied On October 5, 2005 06:30 PM UTC

You can control the dragging of columns by using the TableControlQueryAllowDragColumn event. If you set e.AllowDrag = false, the grid will not do the drag. You could check the e.Column and e.InsertBeforeColumn to prevent dropping of columns between your covered cells. To handle moving all the covered columns at one time, you could check e.Column. If it is a covered column, then you could set e.AllowDrag = false, and then manually move the columns (in the grid.TableDescriptor.Columns collection) to explicitly position all the covered columns yourself.

Badri Rajani Kanth
Replied On October 6, 2005 09:11 AM UTC

Thank You Clay, Using the code given below, I am able to control this to some extent. But still I am unable to move all the colvered columns together to other place. I am trying different options. Can you plz help me by giving some sample. --------------------------------------- private void grdCallSheet_TableControlQueryAllowDragColumn(object sender, GridQueryAllowDragColumnEventArgs e) { //prevent droping columns in between covered columns if (e.InsertBeforeColumn != null && e.TableControl.TableDescriptor.VisibleColumns.IndexOf(e.InsertBeforeColumn) < 4) { e.AllowDrag = false; } //prevent dragging of individual covered columns if (e.Column != null && e.TableControl.TableDescriptor.VisibleColumns.IndexOf(e.Column) < 4) { e.AllowDrag = false; } } --------------------------------------------- Rgds rajani Kanth >You can control the dragging of columns by using the TableControlQueryAllowDragColumn event. > >If you set e.AllowDrag = false, the grid will not do the drag. You could check the e.Column and e.InsertBeforeColumn to prevent dropping of columns between your covered cells. > >To handle moving all the covered columns at one time, you could check e.Column. If it is a covered column, then you could set e.AllowDrag = false, and then manually move the columns (in the grid.TableDescriptor.Columns collection) to explicitly position all the covered columns yourself.

Badri Rajani Kanth
Replied On October 6, 2005 10:56 AM UTC

Hi All, This is in addition to my prev reply. To test my columns moving, I am manually trying to move them. But when try "TableModel.Cols.MoveRange(1, 4, 10);" to move covered colums (columns 1, 2, 3 and 4) to the position of column 10, i dont see any move happening. I dont understand the reason. Actually these columns are in second row(row index 2) of the grid. Is this causing the problem? I have only header info in first row and it is being displayed only as a single-wide column. Rgds Rajani Kanth >Hi All, > >I am displaying data in a GridGroupingControl. I have requirements to >1. Combine few column headers and give them combined caption/header. >2. When user try to move those columns, they should move together. As if they are one column. >3. User should not be able to move some other column into these combined columns. He can only place on either sides of combined columns. But not in between. > >I am able to achive requirement 1. But having problems for 2 and 3. Can any body help me? > >Code sample used for requirement 1: >=================================== > private void TableModel_QueryCoveredRange(object sender, GridQueryCoveredRangeEventArgs e) > { > > GridTableModel tm = sender as GridTableModel; > Element el = tm.Table.DisplayElements[e.RowIndex]; > > if (el is CaptionRow) > { > GridTableCellStyleInfo style = tm[e.RowIndex, e.ColIndex]; > int maxCaptionColCount = Math.Max(tm.Table.TableDescriptor.GetColumnIndentCount(), tm.Table.TableDescriptor.GetColCount()-1); > int startCol = el.GroupLevel+1; > maxCaptionColCount = Math.Min(5+1, maxCaptionColCount); > IGridGroupOptionsSource g = el.ParentGroup as IGridGroupOptionsSource; > if (g != null && !g.GroupOptions.ShowCaptionPlusMinus) > { > startCol--; > } > int d = (el.ParentTable.RelatedTables.Count > 0) ? 1 : 0; > if (!((GridTable) el.ParentTable).TableOptions.ShowRecordPlusMinus) > d = 0; > if (e.ColIndex >= startCol && e.ColIndex <= maxCaptionColCount) > { > e.Range = GridRangeInfo.Cells(e.RowIndex, startCol, e.RowIndex, maxCaptionColCount); > e.Handled = true; > } > } > > if (el is ColumnHeaderRow) > { > GridTableCellStyleInfo style = tm[e.RowIndex, e.ColIndex]; > > if (style.TableCellIdentity.Column.Name == "ContactId" > || > style.TableCellIdentity.Column.Name == "ClientId" > || > style.TableCellIdentity.Column.Name == "ContactPriority" > || > style.TableCellIdentity.Column.Name == "FullName" > ) > { > int startCol = el.GroupLevel+1; > int colIndex = e.ColIndex; > if (style.TableCellIdentity.Column.Name == "ClientId") > colIndex--; > if (style.TableCellIdentity.Column.Name == "ContactPriority") > colIndex = colIndex -2 ; > if (style.TableCellIdentity.Column.Name == "FullName") > colIndex = colIndex -3 ; > e.Range = GridRangeInfo.Cells(e.RowIndex, colIndex, e.RowIndex, colIndex + 3); > e.Handled = true; > } > } > > }

Badri Rajani Kanth
Replied On October 6, 2005 10:57 AM UTC

Hi All, This is in addition to my prev reply. To test my columns moving, I am manually trying to move them. But when try "TableModel.Cols.MoveRange(1, 4, 10);" to move covered colums (columns 1, 2, 3 and 4) to the position of column 10, i dont see any move happening. I dont understand the reason. Actually these columns are in second row(row index 2) of the grid. Is this causing the problem? I have only header info in first row and it is being displayed only as a single-wide column. Rgds Rajani Kanth >Thank You Clay, > >Using the code given below, I am able to control this to some extent. But still I am unable to move all the colvered columns together to other place. I am trying different options. Can you plz help me by giving some sample. >--------------------------------------- > private void grdCallSheet_TableControlQueryAllowDragColumn(object sender, GridQueryAllowDragColumnEventArgs e) > { > //prevent droping columns in between covered columns > > if (e.InsertBeforeColumn != null > && e.TableControl.TableDescriptor.VisibleColumns.IndexOf(e.InsertBeforeColumn) < 4) > { > e.AllowDrag = false; > } > //prevent dragging of individual covered columns > if (e.Column != null > && e.TableControl.TableDescriptor.VisibleColumns.IndexOf(e.Column) < 4) > { > e.AllowDrag = false; > } > } >--------------------------------------------- > > >Rgds >rajani Kanth > >>You can control the dragging of columns by using the TableControlQueryAllowDragColumn event. >> >>If you set e.AllowDrag = false, the grid will not do the drag. You could check the e.Column and e.InsertBeforeColumn to prevent dropping of columns between your covered cells. >> >>To handle moving all the covered columns at one time, you could check e.Column. If it is a covered column, then you could set e.AllowDrag = false, and then manually move the columns (in the grid.TableDescriptor.Columns collection) to explicitly position all the covered columns yourself.

Administrator [Syncfusion]
Replied On October 6, 2005 03:37 PM UTC

You use the grid.TableDescriptor.Columns collection to control the order of the columns. Here is a minimal sample that moves two columns at the same time. http://www.syncfusion.com/Support/user/uploads/GGC_MoveCoveredColumns_f3da58a8.zip

Badri Rajani Kanth
Replied On October 7, 2005 04:26 PM UTC

Clay Burch, Thank You very much. Now, I am able to achive what I wanted. Thank U again. Rajani Kanth >You use the grid.TableDescriptor.Columns collection to control the order of the columns. Here is a minimal sample that moves two columns at the same time. > >http://www.syncfusion.com/Support/user/uploads/GGC_MoveCoveredColumns_f3da58a8.zip > >

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;