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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GDBG. Deleting current row from nested table.

Thread ID:

Created:

Updated:

Platform:

Replies:

14019 May 17,2004 05:54 AM UTC May 17,2004 09:01 AM UTC Windows Forms 3
loading
Tags: GridControl
Silenter
Asked On May 17, 2004 05:54 AM UTC

Hi All. I Delete current row from nested table by this code private void btnDeleteSelectedRow_Click(object sender, System.EventArgs e) { int rowIndex = gridDataBoundGrid1.CurrentCell.RowIndex; GridBoundRecordState rs = gridDataBoundGrid1.Binder.GetRecordStateAtRowIndex(rowIndex); if( rs.ListManager.Current is DataRowView ) { DataRowView drv = (DataRowView)rs.ListManager.Current; if( drv.Row is Dataset1.QuoteRow ) // if row is from nested table { drv.Row.Delete(); gridDataBoundGrid1.Refresh(); } } } BUT, after deleting in the deleted row position I can see empty row. Why? You can test this bug in the next example DeletingNestedRows_3771.zip Regards, Slava.

Administrator [Syncfusion]
Replied On May 17, 2004 07:51 AM UTC

To refresh this child table, you have open and close the parent node. Here is some code.
private void btnDeleteSelectedRow_Click(object sender, System.EventArgs e)
{
	int rowIndex = gridDataBoundGrid1.CurrentCell.RowIndex;
	GridBoundRecordState rs = gridDataBoundGrid1.Binder.GetRecordStateAtRowIndex(rowIndex);
	if( rs.ListManager.Current is DataRowView  )
	{
		DataRowView drv = (DataRowView)rs.ListManager.Current;
		if( drv.Row is Dataset1.QuoteRow )
		{
			drv.Row.Delete();
			//find parent and close & open it
			int level = rs.LevelIndex;
			if(level == 0)
				gridDataBoundGrid1.Refresh();
			else
			{
				int row = rowIndex - 1;
				while (row > this.gridDataBoundGrid1.Model.Rows.HeaderCount)
				{
					rs = gridDataBoundGrid1.Binder.GetRecordStateAtRowIndex(row);
					if(rs.LevelIndex < level)
					{
						this.gridDataBoundGrid1.BeginUpdate();
						this.gridDataBoundGrid1.CollapseAtRowIndex(row);
						this.gridDataBoundGrid1.ExpandAtRowIndex(row);
						this.gridDataBoundGrid1.EndUpdate();
						this.gridDataBoundGrid1.Refresh();
						this.gridDataBoundGrid1.CurrentCell.MoveTo(rowIndex, 1);
						break;
					}
					row--;
				}
			}
		}
	}
}
Here is a forum reference on how to add child rows to an empty child table. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=13894 Here is a sample that shows hold you can insert/delete current rows at any level. updateableexpandgrid631958659068073824.zip

Silenter
Replied On May 17, 2004 08:43 AM UTC

Ok. Thanks a lot. It works. BTW, it difficult enough and it makes my code more difficult . Why I must care about it? Does syncfusion have plans to support this automatically? Regards, Slava.

Administrator [Syncfusion]
Replied On May 17, 2004 09:01 AM UTC

You can take the above code and put it in a method, void RefreshChildTableAtRowIndex(int rowIndex). Then your code will look innocuous like: drv.Row.Delete(); this.grid.RefreshChildTableAtRowIndex(rowIndex); We will look into adding such a method, but adding something that would ''auto respond'' to ListChanged event removing rows in this manner may not be appropriate in all situations. Just exposing the RefreshChildTableAtRowIndex would give you the option of calling it when it is needed.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;