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
300
ManualLoadOnDemand not works for the second level of children
posted

Hi,

I have two problems with my WebHierarchicalDataGrid :

I could find some topic about these problems, but no solution.

First :

I have a 7 level WebHierarchicalDataGrid (It is therefore extremely slow to load all items simultaneously).

I thus chose to load manually each level on demand. The first and second level loading works fine, but from the third an exception is raised : Async Request Failed NullReferenceException, before the RowIslandsPopulating event is raised.


Second :

I expand (successfully) one of the first level's row, then I cannot expand any other row of the same level. The RowIslandsPopulating event is not raised anymore and nothing happen.

 

here's a piece of code (for the 3 firsts levels):

Protected Sub Grid_RowIslandsPopulating(sender As Object, e As Infragistics.Web.UI.GridControls.ContainerRowCancelEventArgs)

        e.Cancel = True

        If e.Row.Expanded Then

            Exit Sub

        End If

        Select Case e.Row.Level

            Case 0

                Me.LoadSecondLevel(e.Row)

            Case 1

                Me.LoadThirdLevel(e.Row)

        End Select

    End Sub

 

    Protected Sub Grid_InitializeRow(sender As Object, e As RowEventArgs)

        Try

            Dim row As ContainerGridRecord = CType(e.Row, ContainerGridRecord)

            If row IsNot Nothing AndAlso row.Level < 7 Then

                row.IsEmptyParent = True

            End If

        Catch ex As Exception

        End Try

    End Sub

 

    Private Sub LoadSecondLevel(pParentRow As ContainerGridRecord)

 

        '--- Clear RowIsland from previous bindings

        pParentRow.RowIslands.Clear()

 

        '--- Crate new child grid

        Dim childGrid As ContainerGrid = New ContainerGrid()

 

        '--- Add the new grid to parent as a row island

        pParentRow.RowIslands.Add(childGrid)

 

        childGrid.AutoGenerateColumns = False

        childGrid.Columns.Clear()

 

        '--- Create columns for the child grid

        Me.CreateSecondLevelColumns(childGrid)

 

        '--- Get the selected software

        Dim softwareId = CInt(pParentRow.Items.FindItemByKey("SoftwareId").Value)

        Dim sofware = Softwares.FirstOrDefault(Function(p_Ele) p_Ele.ID = softwareId)

 

        '--- bind the new grid to the software patches

        If sofware IsNot Nothing Then

            childGrid.DataKeyFields = "ID"

            childGrid.Level = 1

            childGrid.DataSource = sofware.Patchs

            childGrid.DataBind()

        End If

    End Sub

 

    Private Sub LoadThirdLevel(p_ParRow As ContainerGridRecord)

        Try

            '--- Load patch versions

            LoadThirdLevelFirst(p_ParRow)

 

            '--- Load patch customers

            LoadThirdLevelSecond(p_ParRow)

 

        Catch ex As Exception

            ShowError(ex.Message)

            DspErr(ex, "Outils_Patch", "LoadVersionsRowIsland")

        End Try

    End Sub

 

    Private Sub LoadThirdLevelFirst(pParentRow As ContainerGridRecord)

 

        '--- Clear RowIsland from previous bindings

        pParentRow.RowIslands.Clear()

 

        '--- Crate new child grid

        Dim childGrid As ContainerGrid = New ContainerGrid()

 

        '--- Add the new grid to parent as a row island

        pParentRow.RowIslands.Add(childGrid)

 

        childGrid.AutoGenerateColumns = False

        childGrid.Columns.Clear()

 

        '--- Create columns for the child grid

        Me.CreateThirdLevelFirstColumns(childGrid)

 

        Dim patchId = CInt(pParentRow.Items.FindItemByKey("PatchId").Value)

        Dim patch = Patchs.FirstOrDefault(Function(p_Ele) p_Ele.ID = patchId)

 

        If patch IsNot Nothing Then

            childGrid.DataKeyFields = "ID"

            childGrid.Level = 2

            childGrid.DataSource = patch.Versions

            childGrid.DataBind()

        End If

    End Sub

 

    Private Sub LoadThirdLevelSecond(pParentRow As ContainerGridRecord)

        '--- Clear RowIsland from previous bindings

        pParentRow.RowIslands.Clear()

 

        '--- Crate new child grid

        Dim childGrid As ContainerGrid = New ContainerGrid()

 

        '--- Add the new grid to parent as a row island

        pParentRow.RowIslands.Add(childGrid)

 

        childGrid.AutoGenerateColumns = False

        childGrid.Columns.Clear()

 

        '--- Create columns for the child grid

        Me.CreateThirdLevelSecondColumns(childGrid)

 

        Dim patchId = CInt(pParentRow.Items.FindItemByKey("PatchId").Value)

        Dim patch = Patchs.FirstOrDefault(Function(p_Ele) p_Ele.ID = patchId)

 

        If patch IsNot Nothing Then

            childGrid.DataKeyFields = "ID"

            childGrid.Level = 2

            childGrid.ClearDataSource()

            childGrid.DataSource = patch.Organisations

            childGrid.DataBind()

        End If

    End Sub

 

    Private Sub CreateSecondLevelColumns(p_Gri As ContainerGrid)

        '--- Create the 'ID' column

        Dim idField = New Infragistics.Web.UI.GridControls.BoundDataField()

        With idField

            .Header.Text = "Identity"

            .Key = "PatchId"

            .DataFieldName = "ID"

            .Hidden = True

        End With

        p_Gri.Columns.Add(idField)

 

        '--- Create a checkbox column

        Dim checkboxField = New Infragistics.Web.UI.GridControls.UnboundCheckBoxField()

        With checkboxField

            .Key = "DeletePatch"

            .Width = New WebControls.Unit(35, UnitType.Pixel)

        End With

        p_Gri.Columns.Add(checkboxField)

 

        '--- Create a 'Version' column

        Dim versionField = New Infragistics.Web.UI.GridControls.BoundDataField()

        With versionField

            .Header.Text = "Patches"

            .Key = "Version"

            .DataFieldName = "TargetVersion"

            .Width = New WebControls.Unit(35, UnitType.Pixel)

            .Hidden = False

        End With

        p_Gri.Columns.Add(versionField)

 

        '--- Create a 'description' column

        Dim descriptionField = New Infragistics.Web.UI.GridControls.BoundDataField()

        With descriptionField

            .Header.Text = "Description"

            .Key = "Description"

            .DataFieldName = "Description"

            .Width = New WebControls.Unit(80, UnitType.Percentage)

            .Hidden = False

        End With

        p_Gri.Columns.Add(descriptionField)

    End Sub

 

    Private Sub CreateThirdLevelFirstColumns(p_Gri As ContainerGrid)

 

        '--- Create the 'ID' column

        Dim idField = New Infragistics.Web.UI.GridControls.BoundDataField()

        With idField

            .Header.Text = "Identity"

            .Key = "VersionId"

            .DataFieldName = "ID"

            .Hidden = True

        End With

        p_Gri.Columns.Add(idField)

 

        '--- Create a 'Versions' column

        Dim versionsField = New Infragistics.Web.UI.GridControls.BoundDataField()

        With versionsField

            .Header.Text = "Concerned Versions"

            .Key = "Versions"

            .DataFieldName = "ConcernedVersions"

            .Width = New WebControls.Unit(35, UnitType.Pixel)

            .Hidden = False

        End With

        p_Gri.Columns.Add(versionsField)

    End Sub

 

    Private Sub CreateThirdLevelSecondColumns(p_Gri As ContainerGrid)

 

        '--- Create the 'ID' column

        Dim idField = New Infragistics.Web.UI.GridControls.BoundDataField()

        With idField

            .Header.Text = "Identity"

            .Key = "CustomerId"

            .DataFieldName = "ID"

            .Hidden = True

        End With

        p_Gri.Columns.Add(idField)

    End Sub