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

Grouping Grid Caption Row buttons, columns

How can I add buttons to the Group Caption Row of a grouping grid. I need these buttons so that I may perform an action on all the records in a group. Also How can I create a cell in the group caption row so that I may display some related data. Thanks Dev.

3 Replies

AD Administrator Syncfusion Team November 25, 2004 01:24 PM UTC

The 3.0 code ships with a sample, Syncfusion\Essential Suite\\Windows\Grid.Windows\Samples\Grouping\CustomCellTypes, that shows how to put a button in a header cell. Here is a forum thread on showing summary cells in a caption. Here are some other forum links that show other ways you can customized the caption.

DH Devshi Halai November 30, 2004 08:16 AM UTC

Thanks Clay, I''ve got the button on the GroupCaptionCell, by default it appears on the right of the GroupCaptionCell, how can I place the button at any position on the GroupCaptionCell ? My second question is how can I also put extra cells on the GroupCaptionCell. I need to add two extra cells into the GroupCaptionCell ? Thanks Dev.

AD Administrator Syncfusion Team November 30, 2004 02:54 PM UTC

Hi Dev, check out the samples D:\Essential Suite\Windows\Grid.Grouping.Windows\Samples\CustomSectionInGroup and SummaryInCaption It shows how you can handle the TableModel.QueryCoveredRange events and TableModel.QueryCellStyleInfo events in order to place your own contents inside a caption bar or any extra sections of a group To place the button of a custom cell type at a different position you need to do this in the renderers on OnLayout override. First, try to save a reference to the the button when you instantiate it with this.AddButton(new MyCellButton(this)); for example add them to your own ArrayList. ArrayList al = new ArrayList; al.Add(new MyCellButton(this)); this.AddButton((MyCellButton) al[0]); Then you have full access to all buttons. In order to show/hide or position buttons individually you can override the OnLayout method and position buttons or set bounds empty for those you do not want to show. Here is the default implementation of this method: protected virtual Rectangle OnLayout(int rowIndex, int colIndex, GridStyleInfo style, Rectangle innerBounds, Rectangle[] buttonsBounds) { Rectangle clientRectangle = innerBounds; int count = Buttons.Count; if (!Grid.IsPrinting() && count > 0 && this.OnQueryShowButtons(rowIndex, colIndex, style)) { innerBounds.Inflate(-1, -1); int nButtonBarWidth = Model.ButtonBarSize.Width; int width = nButtonBarWidth / count; clientRectangle.Width -= nButtonBarWidth; int height = Math.Min(Model.ButtonBarSize.Height, innerBounds.Height); if (height == 0) height = innerBounds.Height; GridTextAlign textAlign = style.TextAlign; GridVerticalAlignment verticalAlign = style.VerticalAlignment; int yOffset = innerBounds.Top; if (verticalAlign == GridVerticalAlignment.Middle) yOffset += (innerBounds.Height - height)/2; else if (verticalAlign == GridVerticalAlignment.Bottom) yOffset += (innerBounds.Height - height); int xOffset = innerBounds.Left; if ((style.TextAlign == GridTextAlign.Right) != Grid.IsRightToLeft()) clientRectangle.Offset(nButtonBarWidth, 0); else xOffset += innerBounds.Width - nButtonBarWidth; for (int n = 0; n < count; n++) { Rectangle bounds = new Rectangle(xOffset, yOffset, width, height); buttonsBounds[n] = bounds; xOffset += width; } } return clientRectangle; } What is most interesting for you is in the end setting the butonsBounds. You don’t have to worry about the other code, just do something like this: protected override Rectangle OnLayout(int rowIndex, int colIndex, GridStyleInfo style, Rectangle innerBounds, Rectangle[] buttonsBounds) { Rectangle clientRectangle = Base.OnLayout(…); // Position button 0 buttonsBounds[0] = new Rectangle(x, y, width, height); return clientRectangle; } Stefan

Live Chat Icon For mobile
Up arrow icon