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

Summary Row in GridGroupingControl?

Is there a way to put a summary row into the grouping control? I know that the engine can calculate summaries, but is there an easy way to freeze 3 rows at the bottom or to site another grid in order to do summaries?

5 Replies

AD Administrator Syncfusion Team March 5, 2004 11:12 AM UTC

Freezing rows at the bottom is not supported at this time, but is an important feature for us that we will work on soon after 2.0 is out. You could add/site another grid inside the GridTablePanel of the GridGroupingControl and set its DockStyle to Bottom. The idea would be to place there a virtual grid that gets its column widths from the TableControl grid (which is also a child control of GridTablePanel with DockStyle.Fill) and displays the summaries there, but there will be some effort involved. Stefan

AD Administrator Syncfusion Team March 5, 2004 11:38 AM UTC

Attached is some code that adds a grid below the existing tablecontrol grid, but if horizontal scrollbars are shown in the grid, they are drawn above the other grid. public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); this.gridGroupingControl1.ShowNavigationBar = false; GridControl bottomGrid = new GridControl(); bottomGrid.Size = new Size(100, 100); bottomGrid.Dock = DockStyle.Bottom; this.gridGroupingControl1.GridTablePanel.Controls.Add(bottomGrid); } The next code makes use of the GridBounds property of GridControl and embeds the second grid inside the TableControl. Then the scrollbars are drawn as expected. public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // this.oleDbDataAdapter1.Fill(this.dataSet11); this.gridGroupingControl1.Appearance.AnyCell.ImageSizeMode = GridImageSizeMode.CenterImage; this.gridGroupingControl1.ShowNavigationBar = false; GridTableControl tableControl = this.gridGroupingControl1.TableControl; tableControl.GridBounds = new Rectangle(Point.Empty, new Size(tableControl.Width, tableControl.Height-100)); GridControl bottomGrid = new GridControl(); bottomGrid.VScrollBehavior = GridScrollbarMode.Disabled; bottomGrid.HScrollBehavior = GridScrollbarMode.Disabled; bottomGrid.Size = new Size(tableControl.Width, 100); bottomGrid.Location = new Point(0, tableControl.Height-100); bottomGrid.Dock = DockStyle.Bottom; this.gridGroupingControl1.TableControl.Controls.Add(bottomGrid); } The next step here would be to override virtual methods for the second grid and provide summary data. Also, you would have to manually handle size events to correctly resize the bottom grid. When I have some time I''ll look into this a bit further. Stefan

JK Justin Koh March 14, 2004 08:40 PM UTC

I have managed to place a multi row summary grid into my grid. However, I''m having a problem when the grid is very narrow. When I scroll the parent grid, the summary grid either gets drawn over or it draws improperly. I have the grid inside a splitter, so perhaps that is the problem. I''d gotten some sample code from Syncfusion before at http://www.syncfusion.com/Support/article.aspx?id=10398 . This sample works correctly. Is there an issue because I''m using a virtual grid? In the sample, only the layout event handler is captured. Right now I''m also capturing the toprowchanged event and calling "SiteSummaryGrid" and refreshing. This gets rid of the redraw problems, but the scroll bar then cuts off the bottom row. I see that you used DockStyle here, which should take care of the location issue, which means I only have to set the width, right? I''ve also tried to fake the behavior by adding another row depending on if the HScrollBar.InnerScrollbar is visible or not, but it seems that sometimes the area under the scroll bar counts as part of the client area and sometimes it does not. I guess my question out of all of this is... what events do I need to capture? Do I have to reset the gridbounds all the time like in the downloadable sample?

AD Administrator Syncfusion Team March 16, 2004 09:59 AM UTC

If the client area of the main grid is not being set properly, and you are setting the DockStyle of the bottom grid to Bottom and the main grid to Fill, then here s something to check. You need to make sure that you first add the bottom grid to the container, set its dockstyle, and then add the main grid to teh container and set its dockstyle. The reason is that whoever is first in taborder, claims its bounds first. So, if the main grid is added first with Fill, then it covers all the way to the bottom of teh container. Then when you place the bottom grid docked bottom, it will cover part of the main grid''s client area. This seems to be what you are describing. The important point is when teh controls are added. Not when the Dockstyle is set. The KB sample bottom grid tries to avoid this by setting itself as part of the main grid''s client area. It does this by adjusting the GridBounds of the main grid to leave room at the bottom for itself. If you are having multiple rows on bottom, then you would want to make sure the site routine took these multiple rows into account. Here is a try at this that uses the rowcount times the defualtrowheight to get the height of the bottom grid, and uses this height to adjust the GridBounds of the main grid.
public void SiteSummaryRow()
	GridControlBase grid = groupingGrid.TableControl;

	int sumGridHeight = this.summaryGrid.RowCount * grid.DefaultRowHeight;
	grid.GridBounds = new Rectangle(grid.GridBounds.X,
		grid.GridBounds.Height - sumGridHeight);
	int height = grid.GridBounds.Height + sumGridHeight;
	this.summaryGrid.Location = new Point(0, height - sumGridHeight);
	this.summaryGrid.Size = new Size(grid.ClientSize.Width, sumGridHeight);

JK Justin Koh March 16, 2004 01:03 PM UTC

I am adding the summary grid to the main grid''s client area. In the sample, the Layout event of the main grid calls SiteSummaryRow. I had problems with the bottom grid drawing when I tried to scroll the main grid, so I also caught the toprowchanged event and called SiteSummaryRow there. My problem is that I think I''m calling SiteSummaryRow too many times because resizing the main grid is very slow. Do I only need to catch the layout event? Again, the summary grid is in the client area of the main grid because otherwise the scroll bar behavior needs to be synchronized between the 2 grids and that can be flaky.

Live Chat Icon For mobile
Up arrow icon