This is a migrated thread and some comments may be shown as answers.

Double Click a GroupHeader to expand.

3 Answers 194 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 21 Aug 2008, 03:42 AM
Hi,

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.

Thanks
Daniel

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Aug 2008, 10:34 AM
Hi Daniel,

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

CS:
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;  
            }  
            else  
                header.Expanded = false;  
                 
         }  
        
  }  
 
 


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


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


Thanks
Shinu.
0
Shaun Peet
Top achievements
Rank 2
answered on 11 Dec 2008, 05:12 AM
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,

Shaun.
0
Princy
Top achievements
Rank 2
answered on 11 Dec 2008, 12:06 PM
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.

Princy
Tags
Grid
Asked by
Daniel
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Shaun Peet
Top achievements
Rank 2
Princy
Top achievements
Rank 2
Share this question
or