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)
' 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)
' 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
Regards,
Hemesh
Hi Bernd,
Not sure why I wrote SetChildCount, there is no such method. What I meant was that you probably need to set the count on the child rows collection. You would do something like this:
this.ultraDataSource1.Rows[0].GetChildRows(0).SetCount(10);
If this doesn't help, then the same questions I asked above apply here. When you click on the expansion indicator in the grid, then some events on the UltraDataSource should be firing, such as InitializeRowCollection and CellDataRequested. Are these events firing?
Hi Mike,
I want to use the UltrGrid in a similar scenario. Top level rows (parents) are shown correctly. Plus sign for each row is visible. But when I try to show the child rows by clicking the plus sign nothing happens.
Cannot find the SetChildCount function (I'm using Infragistics Version 9.2.20092.2058).
Thanks
Bernd
Hi Hemesh,
mspladmin said: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.
Does CellDataRequested ever get called for a child row? If not, then my best guess is that you need to call SetChildCount on each parent row when it gets created so that the UltraDataSource knows that there are children for that parent row. You also have to expand the row in the grid to trigger the loading of the child rows, of course.
mspladmin said: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.
You probably need to set CellClickAction to SelectRow if you are not showing the RowSelectors. You also have to use either the shift or Ctrl keys in order to select more than one row.