Here is all the code involving Virtual Mode... The only changes made have been to assign a global variable (iRowIndex in GetNodeRow function) that I use elsewhere in the form. The rest of the code is verbatim from the SelfRelatedForm example.
Private Function grid_VirtualMode_GetCount(ByVal sender As NodeBase) As Integer
Dim aNode As NodeBase = sender
If aNode.Depth = -1 Then 'root node
'find rows with Parent == 0//root rows
Dim rows As DataRowView() = GetRows(0)
Return rows.Length
Else
Dim id As Integer = GetNodeId(sender)
Dim childRows As DataRowView() = GetRows(id)
Return childRows.Length
End If
End Function
Private Function HasChildRows(ByVal parentId As Integer) As Boolean
Dim obj As Object = CType(selfRelatedDt.DefaultView.Find(CType(parentId, Integer)), Integer)
Return Not (obj = Nothing)
End Function
Private Function GetRows(ByVal parentId As Integer) As System.Data.DataRowView()
Return selfRelatedDt.DefaultView.FindRows(CType(parentId, Integer))
End Function
Private Function GetNodeId(ByVal node As NodeBase) As Integer
Dim row As DataRowView = GetNodeRow(node)
If row Is Nothing Then
Return -1
Else
Return CType(row("Id"), Integer)
End If
End Function
Private Function GetNodeRow(ByVal node As NodeBase) As DataRowView
Dim parent As NodeBase = node.Parent
If (TypeOf parent Is VirtualRootNode) Then
Dim rows As System.Data.DataRowView() = GetRows(0)
If rows.Length > 0 Then
'Capture node.index to allow for Datatable updates - EAP 10/6/2005
iRowIndex = node.Index
Return rows(node.Index)
End If
Else
Dim parentNodeRow As DataRowView = GetNodeRow(parent)
If (Not parentNodeRow Is Nothing) Then
Dim parentId As Integer = CType(parentNodeRow("Id"), Integer)
Dim rows As System.Data.DataRowView() = GetRows(parentId)
If (rows.Length > 0) Then
'Capture node.index to allow for Datatable updates - EAP 10/6/2005
iRowIndex = node.Index
Return rows(node.Index)
End If
End If
End If
Return Nothing
End Function
Private Function grid_VirtualMode_GetNodeCellValue(ByVal sender As Object, ByVal node As NodeBase, ByVal index As Integer) As Object
Dim parent As NodeBase = node.Parent
Dim dataRow As DataRowView = GetNodeRow(node)
If Not dataRow Is Nothing Then
Dim col As Column = selfRelatedGrid.Columns.VisibleColumns(index)
Return dataRow(col.FieldName)
End If
Return String.Empty
End Function
Private Sub grid_VirtualMode_SetNodeCellValue(ByVal sender As Object, ByVal node As NodeBase, ByVal index As Integer, ByVal value As Object)
Dim row As DataRowView = GetNodeRow(node)
Dim col As Column = selfRelatedGrid.Columns.VisibleColumns(index)
If (Not row Is Nothing) Then
row.BeginEdit()
row(col.FieldName) = value
row.EndEdit()
row.Row.AcceptChanges()
node.Modified = False
End If
End Sub
Private Function grid_VirtualMode_HasChildren(ByVal sender As Object, ByVal node As NodeBase) As Boolean
Dim i As Integer = GetNodeId(node)
If i -1 Then
Return HasChildRows(i)
End If
Return False
End Function
As I have stated before, the code ran (and still does!) on the eval version 1.2.1.39292. It throws an error (at the point shown in the stack trace from my initial post) when I upgrade to Pro version 1.2.3.4.
Aside from the iRowIndex var assignment, my code has not changed since the day I deployed the eval version. If I comment out the var assignments, the Pro version still errors out. It stands to reason that something must have changed in the subsequent revs of FlyGrid leading to the release of 1.2.3.4... Have there been any changes to the demo code that I am basing my code on (I didn't see any, but maybe I didn't look close enough)?
Thanks again for looking into this issue!
Eric