The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
Hi
I use a hierarchical (gridDataBoundGrid) with 2 tables...
I can add and delete childs....
When I delete all the childs, the cross (at the start of the parent line) disappear.....
after I cant add a new child row....
So...
Why I am not able to add new row?
Is there a state for a row to enable adding new childs? Can i activated in the code?
Here is some code I use :
-- add a child row
Public Sub AddChild()
Dim cc As GridCurrentCell = dgbg.CurrentCell
Dim rs As GridBoundRecordState = dgbg.Binder.GetRecordStateAtRowIndex(cc.RowIndex)
''add a new record to the same level
If rs.ListManager.Position >= 0 Then
Dim dr As DataRow = CType(rs.ListManager.Current, DataRowView).Row
Dim dt As DataTable = Me._dataset.Tables(1)
Dim newRow As DataRow = dt.NewRow()
Dim values As Object() = Nothing
values = GetNewValues()
newRow.ItemArray = values
dt.Rows.Add(newRow)
RefreshCurrentParentNode()
End If
End Sub
-- delete a row :
Public Sub DeleteCurrentChildOrParent()
Dim dt As DataTable = Me._dataset.Tables(0)
Dim cc As GridCurrentCell = Me.dgbg.CurrentCell
Dim row As Integer = cc.RowIndex
Dim col As Integer = cc.ColIndex
Dim rs As GridBoundRecordState = dgbg.Binder.GetRecordStateAtRowIndex(cc.RowIndex)
''remove the current record
Dim i As Integer = rs.Position
rs.ListManager.Position = i - 1
Try
rs.ListManager.RemoveAt(i)
RefreshCurrentParentNode()
If row >= Me.dgbg.Model.RowCount Then
row = row - 1
End If
Me.dgbg.CurrentCell.MoveTo(row, col)
Catch ex As Exception
End Try
End Sub
--the refresh methode :
Private Sub RefreshCurrentParentNode()
Dim cc As GridCurrentCell = dgbg.CurrentCell
Dim rs As GridBoundRecordState = dgbg.Binder.GetRecordStateAtRowIndex(cc.RowIndex)
Select Case rs.LevelIndex
Case 0
Me.dgbg.CollapseAtRowIndex(cc.RowIndex)
Me.dgbg.ExpandAtRowIndex(cc.RowIndex)
Case 1
Dim parentLevel As Integer = 0
Dim row As Integer = cc.RowIndex - 1
While row > Me.dgbg.Model.Rows.HeaderCount
rs=dgbg.Binder.GetRecordStateAtRowIndex(row)
If rs.LevelIndex = parentLevel Then
Exit While
End If
row -= 1
End While
Me.dgbg.CollapseAtRowIndex(row)
Me.dgbg.ExpandAtRowIndex(row)
End Select
End Sub
Thanks for your help!
bye
syl