Number of child elements in GridExpanderItem

2 posts, 0 answers
  1. Jan Pfeffer
    Jan Pfeffer avatar
    56 posts
    Member since:
    Aug 2006

    Posted 22 Jun 2011 Link to this post

    Hey at Telerik

    I subscibe to the event below and would like to show in the GridExpanderItem next to the plussign/minussign the number of child elements that exists in child GridViewTemplate.

    All i can do is change the SignStyle, but there is no option for adding text.
    I have tried to change the Text property, the size property and setting DrawTet to true, but with no luck.

    Is there any way to add the text for instance "17" next to the plussign in GridExpanderItem ?

    Perhaps it should be a setting that the number of child elements is shown near the expander.

    I hope you can help me it's very important that the number is shown here to help people save time from expanding the element.

    The tooltip just doesn't get the job done.

    Sincerly Jan



    void rgvEjendomme_ViewCellFormatting(object sender, CellFormattingEventArgs e)




    GridGroupExpanderCellElement cell = e.CellElement as GridGroupExpanderCellElement;



    if (cell != null && e.CellElement.RowElement is GridDataRowElement)




    cell.Expander.Visibility = Telerik.WinControls.ElementVisibility.Visible;

    cell.Expander.ToolTipText =
    "Matrikler: " + ((Ejendom)e.Row.DataBoundItem).Matrikler.Count.ToString();




    if (e.CellElement is GridDetailViewCellElement && e.CellElement.Children.Count != 0)




    var pageView = e.CellElement.Children[0] as RadPageViewStripElement;



    if (pageView == null)









  2. Svett
    Svett avatar
    728 posts

    Posted 27 Jun 2011 Link to this post

    Hi Jan Pfeffer,

    You should create a custom expander cell element to achieve that:

    public class MyGridGroupExpanderCellElement : GridGroupExpanderCellElement
        private LightVisualElement label;
        private StackLayoutElement stackLayout;
        public MyGridGroupExpanderCellElement(GridViewColumn col, GridRowElement row)
            : base(col, row)
        protected override void UpdateInfoCore()
            this.label.Text = this.RowElement.RowInfo.ChildRows.Count.ToString();
        protected override void CreateChildElements()
            this.label = new LightVisualElement();
            this.label.DrawFill = false;
            this.label.DrawText = true;
            this.stackLayout = new StackLayoutElement();
            this.stackLayout.StretchVertically = true;
        protected override Type ThemeEffectiveType
                return typeof(GridGroupExpanderCellElement);

    You should replace the default cell with that one in the CreateCell event:
    private void radGridView1_CreateCell(object sender, GridViewCreateCellEventArgs e)
        if (e.CellType == typeof(GridGroupExpanderCellElement))
            e.CellType = typeof(MyGridGroupExpanderCellElement);

    Notice that you should increase the width of the column:
    this.radGridView1.TableElement.GroupIndent = 50;

    All the best,
    the Telerik team
    Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
Back to Top