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

Help Creating hierarchical grids from design-time

3 Answers 40 Views
Grid
This is a migrated thread and some comments may be shown as answers.
tcl4p
Top achievements
Rank 1
tcl4p asked on 29 Dec 2010, 02:55 AM
I'm using vb.net and tried to set up a Master/Detail hierarchical grid.  I followed the instructions in the documentation "Creating hierarchical grids from design-time" to the letter without success, that is to say when he program ran it looked like a Master/Detail Grid, but when it dropped down to view the detail table there was no data.  I then went back into the property builder and changed the properties for the Detail table and set the Data Source property  to the appropriate data source for the detail table and the detail grid showed up correctly.  The problem however is I could not see the field/column values for the detail table in the property builder.  I then tried to set the column values from the code behind on the load event.  I used the same syntax as in the documentation to try and set the first column visible property value to false as in : TryCast(grdTruckStatus.MasterTableView.Items(0), GridDataItem).ChildItem.NestedTableViews(0).GetColumnSafe("tID").Visible = False
Problem here is when I run the code I get a run time error telling me I have an "Argument Out of Range Exception".  I thought there may be a problem with the detail table so I added the code "MsgBox(Me.grdTruckStatus.MasterTableView.HasDetailTables())", which returned True, so I know the program knows there's a detail table.
I sent the code to support and what they send me is an example project in C#, when I'm using VB, so I was wondering if someone else has come across this problem or can tell me 1. how exactly to set up the hierarchical grid at design time so I can see and change the field/column properties or 2.  If after setting up the Master/Detail you cannot see the detail table fields what is the appropriate syntax is to set the column properties in code behind.

Thanks,
Tom

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 29 Dec 2010, 08:57 AM
Hello,

Try to hide the column of DetailTable in PreRender event like below.

VB.NET:
Protected Sub RadGrid1_PreRender(sender As Object, e As EventArgs)
    RadGrid1.MasterTableView.Items(0).ChildItem.NestedTableViews(0).GetColumnSafe("tID").Visible = False
End Sub

In case of AutoGeneratedColumn, you can hide the column in ColumnCreated event.

Protected Sub RadGrid1_ColumnCreated(sender As Object, e As GridColumnCreatedEventArgs)
    If e.OwnerTableView.Name = "DetailTableName" Then
        'check with name of DetailTable
        If e.Column.UniqueName = "tID" Then
            e.Column.Visible = False
        End If
    End If
End Sub


Thanks,
Princy.
0
tcl4p
Top achievements
Rank 1
answered on 30 Dec 2010, 02:27 AM
Princy,
    Thank you for taking the time to reply.  Unfortunately, the suggestions did not work.  When I moved the line of code to the pre render event I now get a Null Exception error.  I'm sure that I somehow have set up the Master Detail relationship using the property builder incorrectly, but the step by step in the documentation does not work.  Any other suggestions would be welcome!
Tom
0
Princy
Top achievements
Rank 2
answered on 30 Dec 2010, 12:38 PM
Hello,

You can also set the table relations declaratively through the ParentTableRelation property. Please take a look at the following documentation and demo.
Grid / Declarative Relations
Hierarchical data-binding using declarative relations
What you should know

Thanks,
Princy.
Tags
Grid
Asked by
tcl4p
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
tcl4p
Top achievements
Rank 1
Share this question
or