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
315
Ultra Datasource Hierarchical Grids
posted

Hi,

I am trying to use Load on demand with UltraDataSource. My Datasource is a Dataset having 2 table and both are related (Parent - Child).

I am using the code below to show this on my Grid.
But i have not been able to show child rows in the Grid. Please see the code below and suggest me where am i going wrong. A Sample will be most appreciated. Also is it possible to do  Multiple selection on a UltraDatasource without using a Row Selector. My Grid has multiple selection on. But even then i am able to select just 1 row at a time.

Code:

 

    Private Sub LoadDataSource()

        Dim i As Integer

 

 

        Me.UltraDataSource1.Band.Columns.Clear()

 

 

        If AllDrugsDS IsNot Nothing Then

            For i = 0 To AllDrugsDS.Tables(0).Columns.Count - 1

                Me.UltraDataSource1.Band.Columns.Add(AllDrugsDS.Tables(0).Columns(i).ColumnName, AllDrugsDS.Tables(0).Columns(i).DataType)

            Next

 

            Me.UltraDataSource1.Band.ChildBands.Add("1")

 

            For i = 0 To AllDrugsDS.Tables(1).Columns.Count - 1

                Me.UltraDataSource1.Band.ChildBands("1").Columns.Add(AllDrugsDS.Tables(1).Columns(i).ColumnName, AllDrugsDS.Tables(0).Columns(i).DataType)

            Next

 

 

            ' Set the row count. This is how many rows we will have.

            Me.UltraDataSource1.Rows.SetCount(AllDrugsDS.Tables(0).Rows.Count)

 

        End If

 

 

 

        ' Disable any data modifications.

 

        'Me.UltraDataSource1.AllowAdd = False

        'Me.UltraDataSource1.AllowDelete = False

        'Me.UltraDataSource1.ReadOnly = True

 

        ' Set the LoadStyle to LoadOnDemand so the UltraGrid doesn't pre-load

        ' all the rows. LoadOnDemand load style creates rows as they are needed

        ' (for example when they are scrolled into view). You must do this

        ' before setting the DataSource on the UltraGrid.

        '

        Me.grdDrugs.DisplayLayout.LoadStyle = LoadStyle.LoadOnDemand

        Me.grdDrugs.DataSource = Me.UltraDataSource1

 

        ' Disable sorting. If not disabled, when the user sorts rows, UltraGrid

        ' will create all the rows.

        Me.grdDrugs.DisplayLayout.Override.HeaderClickAction = HeaderClickAction.Select

    End Sub

 

    Private Sub UltraDataSource1_CellDataRequested(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinDataSource.CellDataRequestedEventArgs) Handles UltraDataSource1.CellDataRequested

 

        If e.Column.Band.Key <> "Band 0" Then

            e.Data = AllDrugsDS.Tables(1).Rows(e.Row.Index)(e.Column.Index)

        Else

            e.Data = AllDrugsDS.Tables(0).Rows(e.Row.Index)(e.Column.Index)

        End If

 

 

        ' By default UltraDataSource will cache the provided cell value and not ask for

        ' it next time it's needed. Set CacheData to false to prevent UltraDataSource

        ' from doing so.

        e.CacheData = True

 

    End Sub

Regards,

Hemesh

 

Parents Reply Children
No Data