![](/forums/images/avatarimages/default.gif)
is there a way to disable the collapse / expand button in the GridGroupHeaderItem in the RadGrid? Or hide it entirely?
/Lars
5 Answers, 1 is accepted
![](/forums/images/avatarimages/39919b70-532f-465f-8efd-7edb2fc108a71.jpg)
Check out the following help article which explains how to hide the Group expand/collapse column.
Preventing groups expansion by hiding the expand/collapse images
Thanks
Shinu
You can hook up to the ItemCreated event like 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.Clear(); |
(item.Cells[0].Controls[0] as Button).Enabled = false; |
} |
} |
This code will set the expand / collapse button disabled but the button will still be shown in the grid. To completely remove it you can use the commented row instead. For further information about how to customize the GridGroupHeaderItem you can check this help topic.
I hope this helps.
Regards,
Martin
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
![](/forums/images/avatarimages/default.gif)
It works now. :)
/L
![](/forums/images/avatarimages/default.gif)
I am trying to hide this in the Item data bound event while I have the data to evaluate.
It is not finding the button control for the expand button.
Or will I need to find this control at a later time in the event time line?
Protected Sub OnItemDataBoundHandler(ByVal sender As Object, ByVal e As GridItemEventArgs)
If (TypeOf (e.Item) Is GridDataItem) Then
Dim
txtName As TextBox = DirectCast(item.FindControl("tbName"), TextBox)
If txtName.Text = "AMT ST" Or txtName.Text = "AMT OT" Then
Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
item.Expanded =
False
Dim btnExpanded As ImageButton = DirectCast(item.FindControl("btnExpand"), ImageButton)
btnExpand.Visible =
False
End If
End If
End Sub
![](/forums/images/avatarimages/39919b70-532f-465f-8efd-7edb2fc108a71.jpg)
Please take a look into the following code snippet i tried to hide the custom expand/collapse button and Default ExpandCollapse button.
VB:
Protected
Sub
RadGrid1_ItemDataBound(sender
As
Object
, e
As
GridItemEventArgs)
If
TypeOf
e.Item
Is
GridDataItem
Then
Dim
ditem
As
GridDataItem =
DirectCast
(e.Item, GridDataItem)
Dim
txtName
As
TextBox =
DirectCast
(ditem.FindControl(
"tbName"
), TextBox)
If
txtName.Text =
"AMT ST"
Or
txtName.Text =
"AMT OT"
Then
ditem.Expanded =
False
Dim
btnExpanded
As
ImageButton =
DirectCast
(ditem.FindControl(
"btnExpand"
), ImageButton)
btnExpanded.Visible =
False
'for the custom button you give for expand
Dim
Button1
As
Button =
DirectCast
(ditem(
"ExpandColumn"
).Controls(0), Button)
Button1.Visible =
False
' for the default ExpandCollapse Button
End
If
End
If
End
Sub
Thanks,
Shinu.