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

Disable collapse button

5 Answers 325 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lars Friede
Top achievements
Rank 1
Lars Friede asked on 15 Sep 2009, 12:41 PM
Hi,

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

Sort by
0
Shinu
Top achievements
Rank 2
answered on 16 Sep 2009, 04:43 AM
Hi Lars,

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
0
Accepted
Martin
Telerik team
answered on 17 Sep 2009, 11:08 AM
Hello Lars,

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.
0
Lars Friede
Top achievements
Rank 1
answered on 17 Sep 2009, 01:52 PM
Thank you for your replies Martin and Shinu,

It works now. :)

/L
0
Robot B9
Top achievements
Rank 2
answered on 06 Jul 2012, 02:45 PM

 

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

 

0
Shinu
Top achievements
Rank 2
answered on 09 Jul 2012, 07:49 AM
Hi Mark,

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.
Tags
Grid
Asked by
Lars Friede
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Martin
Telerik team
Lars Friede
Top achievements
Rank 1
Robot B9
Top achievements
Rank 2
Share this question
or