Hi,
I need to add a row when ever the user right clicks on the Grid and click Add Comment.Eventhough my grid has many columns this row needs to have a single column one so that I can just add a comment desc and save it. Also I need to drag some rows under it. Is this possible by any means within ultragrid.
Let me know.
Thanks
Nagarjun
Hi Nagarjun,
There's no way to have an empty groups. The groups are created based on the rows within that group. If there is no row of data with a particular value, then you can't show a GroupByRow with nothing in it.
Can we Drag and Drop rows from one Groupby Band to Another
Drag and Drop Functionality works fine when no grouping is done. But once I did the group by, when I try to drag and drop within the same band, it is not happening.
What could be the problem
I think as GroupBy is done based on a column that sorts, it is not allowing drag and drop operation as it alters the sorting order. Because of this,probably it is not doing drag and drop, but if I remove the sortedcolumn entry before the drag starts, it is going against to my goal.
LineItemsGrid.DisplayLayout.Bands(0).SortedColumns.RemoveAt(0)
The grid doesn't have any built-in ability to drag and drop rows. So if your drag/drop works okay when the grid is not grouped and doesn't work when it is grouped, then something is wrong with the code you are using to perform the drag/drop.
nag4054 said:Where could be the problem?
Well, for one thing, every line of code you posted here is commented out. :)
But seriously... The problem is probably that the sample code doesn't account for grouping. It's always using the Move method on the grid's root-level rows collection. But the root-level rows collection will contain GroupByRows in your case. So this code is essentially trying to move a row from a child rows collection under a GroupByRow into the root-level collection.
You can't use the Move method in your case, anyway, because Move only works to move a row to a new position within the same Rows collection to which it already belongs. Moving a row from one group to another would require you to change the data in the row so that the row belongs to the new group.
nag4054 said:Also Is there any way to cut and paste a complete row within a grid?
See the AllowMultiCellOperation property.
The Drag and Drop Code which I am using is the one which I got from one of the samples of infragistics.
Here it is:
'Private Sub LineItemsGrid_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles LineItemsGrid.DragDrop ' Dim dropIndex As Integer ' 'Get the position on the grid where the dragged row(s) are to be dropped. ' 'get the grid coordinates of the row (the drop zone) ' Dim uieOver As UIElement = LineItemsGrid.DisplayLayout.UIElement.ElementFromPoint(LineItemsGrid.PointToClient(New Point(e.X, e.Y))) ' 'get the row that is the drop zone/or where the dragged row is to be dropped ' Dim ugrOver As UltraGridRow = TryCast(uieOver.GetContext(GetType(UltraGridRow), True), UltraGridRow) ' If ugrOver IsNot Nothing Then ' 'index/position of drop zone in grid ' 'band of the drop zone ' dstBand = ugrOver.Band ' dropIndex = ugrOver.Index ' 'get the dragged row(s)which are to be dragged to another position in the grid ' Dim SelRows As SelectedRowsCollection = TryCast(DirectCast(e.Data.GetData(GetType(SelectedRowsCollection)), SelectedRowsCollection), SelectedRowsCollection) ' 'get the count of selected rows and drop each starting at the dropIndex ' For Each aRow As UltraGridRow In SelRows ' 'move the selected row(s) to the drop zone ' LineItemsGrid.Rows.Move(aRow, dropIndex) ' Next ' End If 'End Sub
This code works fine when no grouping is done but when I groupby a particular column, it is not working.
Where could be the problem?
Also Is there any way to cut and paste a complete row within a grid?