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

[Solved] Hiding Hierarchy Expand Icon based on MasterTable Value

1 Answer 137 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark Rowe
Top achievements
Rank 1
Mark Rowe asked on 01 Jun 2009, 07:49 PM
Hey,

I am having a problem hiding the expand icon on a Grid.  I've been trying to follow the examples in the documentation, but I'm trying to do it a little different than what is posted.  I have a column in the master view that tells me if I have additional records in a detail table.  So I'm trying to utilize this column in order to show or hide the expand icon.

Here is an example of what I have so far, but I must admit, I'm really lost.

  Dim nestedViewItems As GridItem() = tableView.GetItems(GridItemType.Item) 
            For Each nestedViewItem As GridItem In nestedViewItems 
                If nestedViewItem.DataItem("AdditionalAddresses") > 0 Then 
                    Dim NestedGridItem As GridNestedViewItem = NestedGridItems(nestedViewItem.ItemIndex) 
                    Dim cell As TableCell = NestedGridItem.NestedTableViews(0).ParentItem("ExpandColumn"
                    cell.Controls(0).Visible = False 
                    nestedViewItem.Visible = False 
                End If 
            Next 

I am getting in the if statement based on my "AdditionalAddresses" column, however, I can't seem to find out how to reference the "expandColumn" cell.

Thanks,
Bob

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 02 Jun 2009, 07:27 AM
Hi Bob,

I hope the 'AdditionalAddresses' is the column in the master table which gives information about the additional records in the detail table. If so you may try the following code snippet in the ItemDataBound event to hide the ExpandCollapse image icon.

VB:
 
    Protected Sub RadGrid1_ItemDataBound(ByVal sender As ObjectByVal e As GridItemEventArgs) 
        If TypeOf e.Item Is GridDataItem Then 
            Dim item As GridDataItem = DirectCast(e.Item, GridDataItem) 
            If item("AdditionalAddresses").Text = "SomeText" Then 
                Dim cell As TableCell = DirectCast(item("ExpandColumn"), TableCell) 
                cell.Controls(0).Visible = False 
            End If 
        End If 
    End Sub 
 
 

Thanks
Shinu
Tags
Grid
Asked by
Mark Rowe
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or