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

Data disappears from unbound grid(first time only) when creating on-demand hierarchical grid/child

2 Answers 70 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Donald
Top achievements
Rank 1
Donald asked on 22 Jun 2011, 07:58 PM
Hi,
I have an unbound radgridview and i am trying to add some on-demand (unbound) hierarchical child/grid to it. It seems i have to "load data in the grid" twice to see data. The first time around, i get to see the columns in the master grid but no data. When i "load data in grid" again, i then get the data.

It seems that when the Master Gird is bound and then i create the on-demand child grid, i can see the data. I must be missing some step in the unbound mode and cannot figure out what. Please could you help?

My code (VS2008) is shown below. The issue is i have to click the Button1 twice to get data .
Thanks
Don

Imports Telerik.WinControls.UI
 
Public Class Form1
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
 
        'clear all data (since we have to click twice to see the data)
        gridReview.Columns.Clear()
        gridReview.Rows.Clear()
 
        'set up columns
        gridReview.Columns.Add(New GridViewTextBoxColumn("ID"))
        gridReview.Columns.Add(New GridViewTextBoxColumn("Employee"))
        gridReview.Columns.Add(New GridViewTextBoxColumn("Code"))
        gridReview.Columns.Add(New GridViewTextBoxColumn("Total Hours"))
        gridReview.Columns.Add(New GridViewCheckBoxColumn("Review"))
 
 
        'setup some grid proerties
        gridReview.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill
        gridReview.AllowAddNewRow = False
        gridReview.AllowDeleteRow = False
        gridReview.ShowGroupPanel = False
        gridReview.Columns(0).ReadOnly = True
        gridReview.Columns(1).ReadOnly = True
        gridReview.Columns(2).ReadOnly = True
 
        'load sample data
        gridReview.Rows.Add(1111, "John Smith", 423, 40.2, False)
        gridReview.Rows.Add(2222, "Jane Doe", 421, 10.2, False)
        gridReview.Rows.Add(3333, "Larry Smith", 423, 23.5, False)
        gridReview.Rows.Add(4444, "Lori Smith", 425, 26.1, False)
 
 
 
 
        'create the hierarchical grid
 
        Dim template As New GridViewTemplate()
        'setup hierarchical grid columns
        Dim id As New GridViewTextBoxColumn("ID")
        Dim shiftdate As New GridViewTextBoxColumn("DisplayDate")
        Dim in1 As New GridViewTextBoxColumn("In1")
        Dim out1 As New GridViewTextBoxColumn("Out1")
        Dim hours As New GridViewTextBoxColumn("Hours")
 
        'setup some hierarchical grid properties
        template.Columns.AddRange(id, shiftdate, in1, out1, hours)
        template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill
        template.AllowAddNewRow = False
        template.AllowDeleteRow = False
        template.AllowEditRow = False
 
        gridReview.Templates.Add(template)
        template.HierarchyDataProvider = New GridViewEventDataProvider(template)
        'not specified relation as its on-demand.
        'code will be put in gridReview_RowSourceNeeded
 
 
 
    End Sub
 
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        AddHandler gridReview.RowSourceNeeded, AddressOf gridReview_RowSourceNeeded
 
    End Sub
 
    Private Sub gridReview_RowSourceNeeded(ByVal sender As Object, ByVal e As GridViewRowSourceNeededEventArgs)
        MessageBox.Show("Show some data")
 
 
    End Sub
 
 
End Class

2 Answers, 1 is accepted

Sort by
0
Donald
Top achievements
Rank 1
answered on 23 Jun 2011, 12:36 PM
Sorry, i posted the issue too soon. Played around with the code and I think i have figured it out now. I needed to load the data in the master grid after all the setups. The sequence should have been:

..Setup unbound master grid
..setup on-demand child/hierarchical grid
..AND THEN load data in the unbound master grid



0
Alexander
Telerik team
answered on 27 Jun 2011, 12:55 PM
Hello Donald,

Thank you for writing.

I am glad you have found how to accomplish your scenario, but still I think your first approach is logically correct and should work. I have added this issue to our PITS and updated your Telerik points. We will address the issue in a future release.

Best regards,
Alexander
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
Donald
Top achievements
Rank 1
Answers by
Donald
Top achievements
Rank 1
Alexander
Telerik team
Share this question
or