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

Relation issue

1 Answer 37 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
steve asked on 27 Dec 2010, 12:14 PM
Hello. Merry Christmas to you all.

I have A radgrid, bound to 2 datasets with hierarchy.

The relation is based upon a number, as it has to keep track of orders entered in the database.
My only issue is that orders that needs to be deliverd, gets a delivery number instead of an order number.
Here's my problem.

So from dataset 1 it loads all the data needed, included the order number. In my child, i call all the records containing that order number.
But when I need to load data for the delivery number, i get zero returns, because the order number acutally can not be changed.

So i need a way to make the grid look if the delivery number is 0, then load based on order number.
If deliver number > 0, then load based on delivery number.

Here's my code.

Hoping someone can help me.

        cmdRittenTemp = New Odbc.OdbcCommand("Select * FROM ritten_temp WHERE ritnummer = '" & RitNummer & "'", cn)
        adpRittenTemp = New Odbc.OdbcDataAdapter(cmdRittenTemp)
        adpRittenTemp.Fill(dsRittenTemp, "ritten_temp")
        cmdGoederenTemp = New Odbc.OdbcCommand("Select * FROM goederen_temp", cn)
        adpGoederenTemp = New Odbc.OdbcDataAdapter(cmdGoederenTemp)
        adpGoederenTemp.Fill(dsGoederenTemp, "goederen_temp")
        ' Me.RadGridViewOverView.MasterTemplate.Templates.Clear()
        RadGridViewOverView.DataSource = dsRittenTemp
        RadGridViewOverView.DataMember = "ritten_temp"
        Dim template As New GridViewTemplate()
        template.DataSource = dsGoederenTemp
        template.DataMember = "goederen_temp"
        Dim relation As New GridViewRelation(RadGridViewOverView.MasterTemplate)
        relation.ChildTemplate = template
        relation.RelationName = "goederenticket"
        RadGridViewOverView.AllowEditRow = False
        RadGridViewOverView.MasterTemplate.Templates(0).AllowEditRow = False

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 29 Dec 2010, 05:58 PM
Hello Steve,

Merry Christmas to you too!

Please review this help article concerning the Load-On-Demand hierarchy. It could help you to achieve your scenario. You can use the RowSourceNeeded event of RadGridView to provide the child rows for the expanded parent row:

private void radGridView1_RowSourceNeeded(object sender, GridViewRowSourceNeededEventArgs e)
    // get the order number from the parent row
    int orderNumber = (int)e.ParentRow.Cells["OrderNumber"].Value;
    // provide child rows
    GridViewRowInfo row = e.Template.Rows.NewRow();

I hope it helps.

Best regards,
the Telerik team
Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question