Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
104
dynamical load child bands
posted

Hi @ all,

 is there a way to load the childbands dynamical for every single row ?

So maybe if the user double_clicks on a parent row in a Grid, the childrows will be loaded from DB and connected to that parentrow. But not for all rows in the grid, only for the one clicked (or the selected ones at click).

I don't see any way to do that with the UltraGrid, because a Relation over two tables will be load every childs !?!

Parents
  • 445
    posted

    Hi Nixa.

    I have done this in a VB.NET project some time ago. When the user clicks on the + of a parent row (master table) the child rows from 2 detail tables are loaded and displayed. If the child rows have allready been loaded nothing happens. I have done this in the following way:

    Private Sub ugArtikelstamm_BeforeRowExpanded(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.CancelableRowEventArgs) Handles ugArtikelstamm.BeforeRowExpanded
          Dim dr As DataRow

          If e.Row.ListObject Is Nothing Then Exit Sub

          dr = CType(e.Row.ListObject, DataRowView).Row         ' get selected master record
          If dr.GetChildRows("FK_LinieA").Length = 0 Then          ' child allready loaded?
             Me.taLinieA.FillByArticleNo(Me.dsModul.tblLinieA, CInt(e.Row.Cells("Artikel_Nr").Value))
          End If
          If dr.GetChildRows("FK_LinieB").Length = 0 Then
             Me.taLinieB.FillByArticleNo(Me.dsModul.tblLinieB, CInt(e.Row.Cells("Artikel_Nr").Value))
          End If
          dr = Nothing
     End Sub

    What you need is a dataset with the corresponding relations from master to detail tables. You also need a method in the detail table where you can load records based on the criteria of the master record. In my example a article number is used. In your code you only have to load the data for the master table. Do not load any data in the detail table. If the load operation can take some time you can set a waitcursor in the BeforeRowExpanded() event and reset it to default in the AfterRowExpanded() event.

    Hope this helps a little bit.

    Ralf

Reply Children