We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Hierarchical GDBG - deleting child rows

Version I execute the following code to delete child records : GridBoundRecordState rs = null; CurrencyManager cm = null; this.BeginUpdate(); for ( int i = bookmarks.Length - 1; i >= 0; i-- ) { rs = this.Binder.GetRecordStateAtRowIndex(bookmarks[i]); if (rsType == RowSelectionType.ParentRows) this.CollapseAtRowIndex(bookmarks[i]); cm = rs.ListManager as CurrencyManager; cm.List.RemoveAt(rs.Position); } this.Selections.Clear(); this.CurrentCell.MoveTo(this.FirstDataRow, this.Model.Cols.HeaderCount+1); if (rsType == RowSelectionType.ChildRows) { int row = this.Model.RowCount-1; while (row >= this.FirstDataRow) { rs = this.Binder.GetRecordStateAtRowIndex(row); if (rs.LevelIndex == 0 && this.IsExpandedAtRowIndex(row)) { this.CollapseAtRowIndex(row); this.ExpandAtRowIndex(row); } row--; } } this.EndUpdate(); If I delete the only child record, the + sign disappears. What needs to be done to make it visible again? I add child records via a context menu and even if I add a child record to this parent (confirmed that I had a matching foreign key) and do a CollapseAll & ExpandAll, the record doesn''t show up in the grid (and neither does the +).

5 Replies

LS Lori S. Pearsall June 17, 2004 01:52 AM UTC

To add to the previous post, the add logic works fine if there''s already a "+" present.

AD Administrator Syncfusion Team June 17, 2004 05:26 AM UTC

Here is a forum thread that discusses this problem. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=13894

LS Lori S. Pearsall June 17, 2004 12:21 PM UTC

I''m a bit concerned about this approach. My Parent is a DataTable and so is the Child and their relation is a DataRelation. What is the implication of adding a "blank" record under the covers? When I ultimately do a DataAdapter.Update are these blank records going to be pushed to the database?

AD Administrator Syncfusion Team June 17, 2004 12:30 PM UTC

I thought you were trying to add a child record to a parent that currently had no children. (The referenced thread did this, adding the appropriate values so the child record so it was not blank, but was populated with the key values so it satisfied the relation so it was put under the proper parent.) Are you trying to do something else?

LS Lori S. Pearsall June 17, 2004 03:59 PM UTC

No - my mistake. I''ve started doing a ExpandAll/CollapseAll in the Form_Load so that the extraneous "+"''s don''t show up. Now I have a consistent appearance on start-up and when I start deleting child records. Your code did the trick - thanks once again!

Live Chat Icon For mobile
Up arrow icon