I am trying to do drag and drop within the same grid. I have a hierarchical DataSet so my grid has several Bands. When I move rows within the same band everything is working fine. But if I want to move row from one band to another - it is not working and row remains at the same place. Actually I think it is trying to drop withing a band causerow sometime moves withing the band.
I am using the following code:
private void ultraGrid1_InitializeLayout(object sender, InitializeLayoutEventArgs e)
ultraGrid1.AllowDrop = true; e.Layout.Override.SelectTypeRow = SelectType.ExtendedAutoDrag; e.Layout.Override.RowSelectors = Infragistics.Win.DefaultableBoolean.True; e.Layout.Override.CellClickAction = CellClickAction.RowSelect;
private void ultraGrid1_DragDrop(object sender, DragEventArgs e)
aRow.ParentCollection.Move(aRow, dropIndex); // cause I am not moving upper level rows
Thank you so much!
Now it works fine!
Hm, that's odd. Does the Refresh method have a second param for recursive? Maybe you need to pass in true.
Just as a test, what if you set the grid's DataSource to null and then back to the real data source? That should wipe out everything and re-bind the grid. If that doesn't work, then something is wrong with the code that's moving the row in the data source. If it does work, then we will have to find a way to refresh the rows in the grid without destroying everything. It's possible that you can't, but I think it should be doable.
After I added ultraGrid1.Rows.Refresh(RefreshRow.ReloadData); - newly added rows was not displayed.
If you have correctly "moved" the row to a new parent row in the data source, then you probably need to call grid.Rows.Refresh(ReloadData) to get the grid to reflect the change.
I am modifying DataSourse. My DataSource is like this:
_ReportSeries = new DataSet(); _ReportSeries.Tables.Add(VWA4Common.DB.Retrieve("SELECT * FROM ReportSeries WHERE SiteID = " + siteID)); _ReportSeries.Tables[0].TableName = "ReportSeries"; _ReportSeries.Tables.Add(VWA4Common.DB.Retrieve("SELECT * FROM ReportSeries LEFT JOIN " + " (ReportSet LEFT JOIN ReportMemorized ON ReportSet.ReportMemorized = ReportMemorized.ID ) " + " ON ReportSet.SerieID = ReportSeries.ID WHERE ReportSeries.SiteID = " + siteID + " ORDER BY [Order]")); _ReportSeries.Tables[1].TableName = "ReportSet"; _ReportSeries.Relations.Add(new DataRelation("ReportSet", _ReportSeries.Tables["ReportSeries"].Columns["ID"], _ReportSeries.Tables["ReportSet"].Columns["SerieID"]));
So subtable connected to main Table via SerieID. So in private void ultraGrid1_DragDrop(object sender, DragEventArgs e) I modify thisSerieID like this:
foreach (UltraGridRow aRow in SelRows){ DataRow dataRow = ((DataRowView)aRow.ListObject).Row; dataRow["ReportSeries.ID"] = ugrOver.Cells["ID"].Value; dataRow["SerieName"] = ugrOver.Cells["SerieName"].Value; dataRow["SiteID"] = ugrOver.Cells["SiteID"].Value;
aRow.ParentCollection.Move(aRow, dropIndex);
}
ultraGrid1.Refresh();
But row remains in the same place. How to force relation to change?
Mila.