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

Rad grid relation problem

1 Answer 126 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Prasad
Top achievements
Rank 1
Prasad asked on 06 Jun 2011, 03:01 PM
Hi there,

Iam using a radgrid for that we are creating Parent-child relation programatically.It works fine for the first time (refer screen shot1) when loading. But if we have done any update operation or if we are again trying to load the page.It is creating multiple tables in the Child grid view(refer screen shot 2).We are calling that creating relation method again in Update operation if it is not called the changes done are not reflecting in the child grid.Here is the code how we are programatically binding.
radGrid_MultiplePI.DataSource = Nothing
            Dim ds1 As New DataSet()
            Dim ds2 As New DataSet()
            ds1 = objdalProtocolSetupWizard.displayProtocolandInstitutions(cmbProtocolNumber.SelectedValue)
            Me.radGrid_MultiplePI.MasterGridViewTemplate.DataSource = Nothing
            Me.radGrid_MultiplePI.MasterGridViewTemplate.AllowAddNewRow = False
            Me.radGrid_MultiplePI.MasterGridViewTemplate.AllowDeleteRow = False
            radGrid_MultiplePI.DataSource = ds1.Tables("Institutions")
            radGrid_MultiplePI.Columns(1).IsVisible = False
            radGrid_MultiplePI.Columns(1).Width = 150
            radGrid_MultiplePI.Columns(2).Width = 150
            Dim template As New GridViewTemplate()
            template.BeginInit()
            template.DataSource = Nothing
            radGrid_MultiplePI.MasterGridViewTemplate.ChildGridViewTemplates.Insert(0, template)
              template.AllowAddNewRow = False
            template.AllowEditRow = False
            template.AllowDeleteRow = False
            template.DataSource = ds1.Tables("Investigators")
            Dim relation As New GridViewRelation(radGrid_MultiplePI.MasterGridViewTemplate)
            relation.ChildTemplate = template
            relation.RelationName = "InstitutionInvestigators"
            relation.ParentColumnNames.Add("ID")
            relation.ChildColumnNames.Add("ID")
            template.Columns(0).Width = 100
            template.Columns(1).Width = 100
            template.Columns(0).IsVisible = False
            radGrid_MultiplePI.Relations.Add(relation)
            template.EndInit()
            radGrid_MultiplePI.Refresh()
Production release is scheduled very soon it's need to be resolved asap.Looking forward for your reply.

Thanks,
Prasad

1 Answer, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 09 Jun 2011, 12:20 PM
Hello Prasad,

For your scenario the Templates collection of RadGridView control must be cleared before setting up the hierarchy mode again. The best solution for this case is to call the Reset method of MasterTemplate:

radGrid_MultiplePI.DataSource = Nothing
Dim ds1 As New DataSet()
Dim ds2 As New DataSet()
ds1 = objdalProtocolSetupWizard.displayProtocolandInstitutions(cmbProtocolNumber.SelectedValue)
 
radGrid_MultiplePI.MasterTemplate.Reset()
 
radGrid_MultiplePI.MasterTemplate.DataSource = Nothing
radGrid_MultiplePI.MasterTemplate.AllowAddNewRow = False
radGrid_MultiplePI.MasterTemplate.AllowDeleteRow = False
radGrid_MultiplePI.DataSource = ds1.Tables("Institutions")
radGrid_MultiplePI.Columns(1).IsVisible = False
radGrid_MultiplePI.Columns(1).Width = 150
radGrid_MultiplePI.Columns(2).Width = 150
Dim template As New GridViewTemplate()
template.BeginInit()
template.DataSource = Nothing
radGrid_MultiplePI.MasterTemplate.ChildGridViewTemplates.Insert(0, template)
template.AllowAddNewRow = False
template.AllowEditRow = False
template.AllowDeleteRow = False
template.DataSource = ds1.Tables("Investigators")
Dim relation As New GridViewRelation(radGrid_MultiplePI.MasterTemplate)
relation.ChildTemplate = template
relation.RelationName = "InstitutionInvestigators"
relation.ParentColumnNames.Add("ID")
relation.ChildColumnNames.Add("ID")
template.Columns(0).Width = 100
template.Columns(1).Width = 100
template.Columns(0).IsVisible = False
radGrid_MultiplePI.Relations.Add(relation)
template.EndInit()
radGrid_MultiplePI.Refresh()

I hope this information is useful. Let me know if you need further assistance.

Best wishes,
Julian Benkov
the Telerik team
Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
Tags
GridView
Asked by
Prasad
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Share this question
or