Hi All - I am using current build of aspjax controls. I have been having a real problem getting columns to line up in hierarchical self referencing grid. I have gone through all the other posts here that I could find to no avail... :
http://www.telerik.com/support/kb/aspnet-ajax/grid/aligning-columns-in-each-level-of-self-referencing-grid.aspx
http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/selfreferencing/defaultcs.aspx
http://www.telerik.com/community/forums/aspnet-ajax/grid/self-referencing-hierarchy-on-radgrid.aspx
however, I finally figured out a tweak that seems to work for me, so I thought I would post for everyone.
The symotom is that I get a graduated spacing as the columns move left, and which is differnt in scale as I go down in hierarchical level. I have attached example of problem.
To fix it, I have to pad the cells with different settings depending on where they fall in the grid. The code that seems to work for me is here:
Public Sub Page_PreRenderComplete(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.PreRenderComplete
HideExpandColumnRecursive(RadGrid1.MasterTableView)
End Sub
Public Sub HideExpandColumnRecursive(ByVal tableView As GridTableView)
Dim nestedViewItems As GridItem() = tableView.GetItems(GridItemType.NestedView)
For Each nestedViewItem As GridNestedViewItem In nestedViewItems
nestedViewItem.HorizontalAlign = HorizontalAlign.Right
For Each nestedView As GridTableView In nestedViewItem.NestedTableViews
nestedView.HorizontalAlign = HorizontalAlign.Right
nestedView.Style("border") = "0"
nestedView.Style("padding-left") = "0px"
nestedView.Style("padding-right") = "0px"
Dim MyExpandCollapseButton As Button = DirectCast(nestedView.ParentItem.FindControl("MyExpandCollapseButton"), Button)
If nestedView.Items.Count = 0 Then
If Not IsNothing(MyExpandCollapseButton) Then
MyExpandCollapseButton.Style("visibility") = "hidden"
End If
nestedViewItem.Visible = False
Else
If Not IsNothing(MyExpandCollapseButton) Then
MyExpandCollapseButton.Style.Remove("visibility")
End If
'Need to set graduate padding for lower level to avoid V alignment problem
For Each item As GridItem In nestedView.Items
Dim level As Integer = item.ItemIndexHierarchical.Split(":"c).Length
If level = 2 Then
Dim nPad As Integer = 0
For i As Integer = 2 To item.Cells.Count - 1 'ignore first col
If i < 6 Then
nPad = 18
ElseIf i > 5 And i < 10 Then
nPad = 12
Else
nPad = 8
End If
item.Cells(i).Style("padding-right") = nPad & "px !important"
Next
End If
If level = 3 Then
Dim nPad As Integer = 0
For i As Integer = 2 To item.Cells.Count - 1 'ignore first col
If i < 6 Then
nPad = 25
ElseIf i > 5 And i < 7 Then
nPad = 20
ElseIf i > 6 And i < 10 Then
nPad = 15
Else
nPad = 10
End If
item.Cells(i).Style("padding-right") = nPad & "px !important"
Next
End If
Next
End If
If nestedView.HasDetailTables Then
HideExpandColumnRecursive(nestedView)
End If
Next
Next
End Sub
http://www.telerik.com/support/kb/aspnet-ajax/grid/aligning-columns-in-each-level-of-self-referencing-grid.aspx
http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/selfreferencing/defaultcs.aspx
http://www.telerik.com/community/forums/aspnet-ajax/grid/self-referencing-hierarchy-on-radgrid.aspx
however, I finally figured out a tweak that seems to work for me, so I thought I would post for everyone.
The symotom is that I get a graduated spacing as the columns move left, and which is differnt in scale as I go down in hierarchical level. I have attached example of problem.
To fix it, I have to pad the cells with different settings depending on where they fall in the grid. The code that seems to work for me is here:
Public Sub Page_PreRenderComplete(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.PreRenderComplete
HideExpandColumnRecursive(RadGrid1.MasterTableView)
End Sub
Public Sub HideExpandColumnRecursive(ByVal tableView As GridTableView)
Dim nestedViewItems As GridItem() = tableView.GetItems(GridItemType.NestedView)
For Each nestedViewItem As GridNestedViewItem In nestedViewItems
nestedViewItem.HorizontalAlign = HorizontalAlign.Right
For Each nestedView As GridTableView In nestedViewItem.NestedTableViews
nestedView.HorizontalAlign = HorizontalAlign.Right
nestedView.Style("border") = "0"
nestedView.Style("padding-left") = "0px"
nestedView.Style("padding-right") = "0px"
Dim MyExpandCollapseButton As Button = DirectCast(nestedView.ParentItem.FindControl("MyExpandCollapseButton"), Button)
If nestedView.Items.Count = 0 Then
If Not IsNothing(MyExpandCollapseButton) Then
MyExpandCollapseButton.Style("visibility") = "hidden"
End If
nestedViewItem.Visible = False
Else
If Not IsNothing(MyExpandCollapseButton) Then
MyExpandCollapseButton.Style.Remove("visibility")
End If
'Need to set graduate padding for lower level to avoid V alignment problem
For Each item As GridItem In nestedView.Items
Dim level As Integer = item.ItemIndexHierarchical.Split(":"c).Length
If level = 2 Then
Dim nPad As Integer = 0
For i As Integer = 2 To item.Cells.Count - 1 'ignore first col
If i < 6 Then
nPad = 18
ElseIf i > 5 And i < 10 Then
nPad = 12
Else
nPad = 8
End If
item.Cells(i).Style("padding-right") = nPad & "px !important"
Next
End If
If level = 3 Then
Dim nPad As Integer = 0
For i As Integer = 2 To item.Cells.Count - 1 'ignore first col
If i < 6 Then
nPad = 25
ElseIf i > 5 And i < 7 Then
nPad = 20
ElseIf i > 6 And i < 10 Then
nPad = 15
Else
nPad = 10
End If
item.Cells(i).Style("padding-right") = nPad & "px !important"
Next
End If
Next
End If
If nestedView.HasDetailTables Then
HideExpandColumnRecursive(nestedView)
End If
Next
Next
End Sub