Double Click a GroupHeader to expand.

4 posts, 0 answers
  1. Daniel
    Daniel avatar
    40 posts
    Member since:
    Oct 2007

    Posted 20 Aug 2008 Link to this post


    I have a RadGrid that is grouped by one of the columns.
    When i double click a GroupHeader, i want the group to be expanded. I want it to behave in the same way (Client Side) as it is done when i click on (+) image on the left side of the groupHeader.

    I have a client event RowDbClick(). When i double click the row i can figure out whether it is clicked on the GroupHeaderItem. After this how can i expand the group?
    Pls do help me on this.

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 21 Aug 2008 Link to this post

    Hi Daniel,

    Try the following code snippet to expand a Group on double clicking its Group header.

    protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)  
            if (e.Item is GridGroupHeaderItem)  
                GridGroupHeaderItem header = (GridGroupHeaderItem)e.Item;  
                string strExp = header.DataCell.Text;  
                header.Attributes.Add("onDblClick ", "return Expand('" + strExp + "');");  
    protected void RadGrid1_PreRender(object sender, EventArgs e)  
             foreach (GridGroupHeaderItem header in RadGrid1.MasterTableView.GetItems(GridItemType.GroupHeader))  
                if (header.DataCell.Text == Hidden1.Value)  
                    header.Expanded = true;  
                    header.Expanded = false;  

    <script type="text/javascript" language="javascript" > 
            function Expand(strExp)  
               var Hidden1document.getElementById("Hidden1");    
               __doPostBack('<%=RadGrid1.ClientID %>');  

     <input id="Hidden1" name="Hidden1" runat="server" type="hidden" />  

  3. DevCraft R3 2016 release webinar banner
  4. Shaun Peet
    Shaun Peet avatar
    571 posts
    Member since:
    Aug 2004

    Posted 10 Dec 2008 Link to this post

    Hi Guys,

    This does work, but it causes a server postback, and that's not what the original question was asking for.  It also doesn't allow for the collapsing of an item after its been expanded.

    So I've been scouring the forums for an hour looking for a way to have the expand/collapse client-side functionality apply to the text of the group header item - either instead of, or in addition to, the expand/collapse icon, and haven't been able to find the answer.  This thread is the closest I've seen, but it's not quite what we're after.  Is this possible?  Many thanks,

  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 11 Dec 2008 Link to this post

    Hi Shaun,

    The sample code provided above will work only with a postback. Shinu has submitted a CodeLibrary regarding this.
    I have found another code library submission which shows how to expand/collapse grouped grid client-side on external control click.

Back to Top