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

Don't Allow Group Collapse

3 Answers 64 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 19 Oct 2009, 07:26 PM
I have a RadGrid that groups data based on a column's value, and would like the user to not be allowed to expand/collapse that group (I'm essentially grouping only so I can have a group title).  My RadGrid is defined as follows:

<!-- RadGrid for Articles --> 
<telerik:RadGrid runat="server" ID="rgArticles" AutoGenerateColumns="false" AllowSorting="false" GroupingEnabled="true">  
    <MasterTableView ShowHeader="false">  
      
        <%-- Columns --%> 
        <Columns> 
            <%-- Title --%> 
            <telerik:GridTemplateColumn> 
                <ItemTemplate><a href="<%#Eval("EditionLocation")%>" title="<%#Eval("Summary")%>" target="_blank"><%#Eval("Title")%> (p<%#Eval("EditionPages")%>)</a></ItemTemplate>  
            </telerik:GridTemplateColumn> 
        </Columns> 
          
        <%-- GroupByExpressions --%> 
        <GroupByExpressions> 
            <telerik:GridGroupByExpression> 
                <SelectFields> 
                    <telerik:GridGroupByField FieldName="Edition" HeaderValueSeparator="Edition: " HeaderText="<%=String.Empty %>" /> 
                </SelectFields> 
                <GroupByFields> 
                    <telerik:GridGroupByField FieldName="Edition" /> 
                </GroupByFields> 
            </telerik:GridGroupByExpression> 
        </GroupByExpressions> 
          
    </MasterTableView> 
</telerik:RadGrid> 

How can I make this work?  Thank you!

3 Answers, 1 is accepted

Sort by
0
Accepted
Schlurk
Top achievements
Rank 2
answered on 19 Oct 2009, 07:59 PM
You could try this:
 
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)  
{  
   if (e.Item is GridGroupHeaderItem)  
   {  
       GridGroupHeaderItem item = (GridGroupHeaderItem)e.Item;  
       DataRowView groupDataRow = (DataRowView)e.Item.DataItem;  
       (item.Cells[0].Controls[0] as Button).Enabled = false;  
   }  
}  

This will disable your button, and if you want to remove the button completely (aka remove the image etc.) you would do:
 
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)  
{  
   if (e.Item is GridGroupHeaderItem)  
   {  
       GridGroupHeaderItem item = (GridGroupHeaderItem)e.Item;  
       DataRowView groupDataRow = (DataRowView)e.Item.DataItem;  
       item.Cells[0].Controls.Clear();   
   }  
}  

Hope this helps!


0
Ryan
Top achievements
Rank 1
answered on 19 Oct 2009, 08:03 PM
That did the trick!  Thanks for the prompt reply!
0
Mati
Top achievements
Rank 1
answered on 14 Jan 2017, 01:50 AM

Hi,

 

Could you tell me how I can add a custom css class to the expand buttons on each group? Or how to get in client side all the expand buttons have been disabled from server side?

 

Thanks in advance!

Tags
Grid
Asked by
Ryan
Top achievements
Rank 1
Answers by
Schlurk
Top achievements
Rank 2
Ryan
Top achievements
Rank 1
Mati
Top achievements
Rank 1
Share this question
or