Xceed SupportMemberJanuary 30, 2007 at 10:08 amPost count: 5658
I have a problem with databound and detail grids. I don’t know exactly if my thinking is wrong or if there is no solution. Here is my problem:
I have a grid Control which is build like a tree control (See Explorer example in Xceed documentation). There are different reasons not to use a treeView, but there are unimportant here.
This means that there is a System-Grid which have a Port detailgrid. The Port grid itself has a detailgrid called Devices. All grids are bound to a dataset structure.
Now f.e. I will move a “Device xy” from “Port 1” to “Port 2”. Therefore I check CurrentRow, search the corresponding DataRow and change its parent. Source Code look like this:
private void toolMoveUp_Click(object sender, Xceed.SmartUI.SmartItemClickEventArgs e)
Xceed.Grid.DataRow xrow = gridControl.CurrentRow as Xceed.Grid.DataRow;
DataRowView rowView = xrow.SourceObject as DataRowView;
DataRow dataRow = rowView.Row;
System.Data.DataRelation rel = dataRow.Table.ParentRelations;
DataRow parent = dataRow.GetParentRow(rel);
if (parent.Table.Rows[i] == parent)
parent = parent.Table.Rows[i-1];
This code works fine, but I want that the moved row will remain selected. Currently the selection still remains on the “old” position (this means before moving the row).
I found no way to get the new position of the moved cell and have also no idea about how to get the corresponding Xceed.Grid.DataRow from a System.Data.DataRow.
Idea’s about optimizing this procedure are also welcome.
Thx Frank Weingaertner
Imported from legacy forums. Posted by Frank (had 1867 views)User (Old forums)MemberJanuary 31, 2007 at 4:47 pmPost count: 23064
Moving rows right into the data source makes it difficult to find the right row, and the only solution we see is to go through the whole grid to find it.
One solution would be to use the grid to move the row.
For example, for a MoveUp, you could find the ParentGrid.ParentDataRow, get the row above this one, and set the foreign key value of the row to be moved to the value of the above row. This way, the grid will move the row into the right detail grid, and you will be able to select it again.
Another solution would be to store the cell values into a buffer, delete the row, and add a new row in the detail grid you want, set its values, then select it.
Imported from legacy forums. Posted by André (had 2940 views)
- You must be logged in to reply to this topic.