Markus Giera
Top achievements
Rank 1
Markus Giera
asked on 20 Jul 2010, 08:09 AM
Hello
First of all: great update, the Gridview in Q2 2010!
Still, what is causing me headache is the new drag and drop capability:
If I use the code snippets from the samples:
the events only get fired when dragging the column (
First of all: great update, the Gridview in Q2 2010!
Still, what is causing me headache is the new drag and drop capability:
If I use the code snippets from the samples:
ddService = radHView1.GridViewElement.GetService<Telerik.WinControls.RadDragDropService>(); ddService.PreviewDragOver += new System.EventHandler<Telerik.WinControls.RadDragOverEventArgs>(_ddService_PreviewDragOver); ddService.PreviewDragDrop += new System.EventHandler<Telerik.WinControls.RadDropEventArgs>(_ddService_PreviewDragDrop); ddService.PreviewDragHint += new System.EventHandler<Telerik.WinControls.PreviewDragHintEventArgs>(_ddService_PreviewDragHint); the events only get fired when dragging the column (
GridCellElement ) as shown in the example
http://www.telerik.com/community/forums/winforms/gridview/drag-amp-drop-functionalities-to-swap-column.aspx
For the data-bound Gridrows the events do not get fired.
Am I doing something wrong? Is there any kind of documentation for the new drag and drop mechanism?
Thanks
Markus7 Answers, 1 is accepted
0
Markus Giera
Top achievements
Rank 1
answered on 20 Jul 2010, 09:43 AM
Update:
Problem only occurs in data-bound mode.
In unbound mode the events get fired.
So two questions:
1. Can drag and drop be done in DATA-BOUND mode?
2. Can a self-referencing hierarchy be done in UN-BOUND mode?
Thank you.
Marku
Problem only occurs in data-bound mode.
In unbound mode the events get fired.
So two questions:
1. Can drag and drop be done in DATA-BOUND mode?
2. Can a self-referencing hierarchy be done in UN-BOUND mode?
Thank you.
Marku
0
Hi Markus Giera,
Presently, it is not possible to reorder rows when you are in bound mode (neither if sorting or grouping is applied). This is the desired behavior because of the logical mismatch with the other features of RadGridView. You can customize the behavior and implement your scenario by allowing the drag and drop feature of GridDataRowElement instances in the RowFormatting event. Also you need to start the RadGridViewDragDropService in the MouseDownLeft event of the grid. Then you need to handle the appropriate events of the service, where you can implement your case. You can use the following code snippet as sample:
Let me known if you need further assistance.
Kind regards,
Svett
the Telerik team
Presently, it is not possible to reorder rows when you are in bound mode (neither if sorting or grouping is applied). This is the desired behavior because of the logical mismatch with the other features of RadGridView. You can customize the behavior and implement your scenario by allowing the drag and drop feature of GridDataRowElement instances in the RowFormatting event. Also you need to start the RadGridViewDragDropService in the MouseDownLeft event of the grid. Then you need to handle the appropriate events of the service, where you can implement your case. You can use the following code snippet as sample:
public partial class Form1 : Form{ public Form1() { InitializeComponent(); RadGridViewDragDropService dragDropService = this.radGridView2.GridViewElement.GetService<RadGridViewDragDropService>(); dragDropService.PreviewDragStart += new EventHandler<Telerik.WinControls.PreviewDragStartEventArgs>(dragDropService_PreviewDragStart); dragDropService.PreviewDragDrop += new EventHandler<Telerik.WinControls.RadDropEventArgs>(dragDropService_PreviewDragDrop); this.radGridView2.RowFormatting += new RowFormattingEventHandler(radGridView2_RowFormatting); BaseGridBehavior gridBehavior = this.radGridView2.GridBehavior as BaseGridBehavior; gridBehavior.UnregisterBehavior(typeof(GridViewDataRowInfo)); gridBehavior.RegisterBehavior(typeof(GridViewDataRowInfo), new MyGridDataRowBehavior()); } void dragDropService_PreviewDragDrop(object sender, Telerik.WinControls.RadDropEventArgs e) { // you should mark the event as handled // this will prevent executing of default drag-n-drop logic for unbound mode // which is not working in bound mode e.Handled = true; // YOUR LOGIC HERE } void dragDropService_PreviewDragStart(object sender, Telerik.WinControls.PreviewDragStartEventArgs e) { e.CanStart = true; } void radGridView2_RowFormatting(object sender, RowFormattingEventArgs e) { // This enables row elements to be dragged and dropped e.RowElement.AllowDrag = true; e.RowElement.AllowDrop = true; } protected override void OnLoad(EventArgs e) { base.OnLoad(e); this.radGridView2.DataSource = DataTableDumper.GenerateEmployees(); } public class MyGridDataRowBehavior : GridDataRowBehavior { protected override bool OnMouseDownLeft(MouseEventArgs e) { GridDataRowElement dataRowElement = this.GetRowAtPoint(e.Location) as GridDataRowElement; if (dataRowElement != null) { RadGridViewDragDropService dragDropService = this.GridViewElement.GetService<RadGridViewDragDropService>(); dragDropService.Start(dataRowElement); } return base.OnMouseDownLeft(e); } }}Let me known if you need further assistance.
Kind regards,
Svett
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Markus Giera
Top achievements
Rank 1
answered on 27 Jul 2010, 07:51 PM
Hello Svett
Thank you for your answer and your efforts.
We could try your solution and it's working in bound-mode.
BUT: only in non-hierarchical scenarios. In our hierarchical program, the solution doesn't work.
It's a pity, we just need to enable drag and drop of child-objects to other parents. Should not be such a problem, should it?
Any suggestions?
Greets - Markus
Thank you for your answer and your efforts.
We could try your solution and it's working in bound-mode.
BUT: only in non-hierarchical scenarios. In our hierarchical program, the solution doesn't work.
It's a pity, we just need to enable drag and drop of child-objects to other parents. Should not be such a problem, should it?
Any suggestions?
Greets - Markus
0
Nick
Top achievements
Rank 1
answered on 28 Jul 2010, 11:00 AM
Hi,
Can one drag and drop between two different grids. The grids are also located in diffrent Usercontrols as well. We are using WinForms.
Can one drag and drop between two different grids. The grids are also located in diffrent Usercontrols as well. We are using WinForms.
0
Hi Nick,
You can achieve that easily by using RadGridViewDragDropService. You can read more about it in this blog post. Also you can refer to the code in our Rows Drag and Drop demo in the supplied examples with the installation.
All the best,
Svett
the Telerik team
You can achieve that easily by using RadGridViewDragDropService. You can read more about it in this blog post. Also you can refer to the code in our Rows Drag and Drop demo in the supplied examples with the installation.
All the best,
Svett
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Markus Giera
Top achievements
Rank 1
answered on 30 Jul 2010, 09:27 PM
Hi Nick
the drag and drop mechanism works good in a for non-hierarchical grids. For hierarchy we weren't able until now to get it running.
Best regards
Markus
the drag and drop mechanism works good in a for non-hierarchical grids. For hierarchy we weren't able until now to get it running.
Best regards
Markus
0
Hi Markus Giera,
The issue is cause by the extended grid behavior, where the drag operation is defined only for GridViewDataRowInfo instances. In hierarchy mode the rows produced by RadGridView instance are GridViewHierarchyRowInfo. You need to extend another behavior instead. You can use the following code snippet:
You need to replace the default behavior with its extended version:
Kind regards,
Svett
the Telerik team
The issue is cause by the extended grid behavior, where the drag operation is defined only for GridViewDataRowInfo instances. In hierarchy mode the rows produced by RadGridView instance are GridViewHierarchyRowInfo. You need to extend another behavior instead. You can use the following code snippet:
Public Class MyGridBehavior Inherits BaseGridBehavior Public Overrides Function OnMouseDown(ByVal e As MouseEventArgs) As Boolean Dim result As Boolean = MyBase.OnMouseDown(e) If e.Button = MouseButtons.Left Then Dim dataRowElement As GridDataRowElement = TryCast(Me.RowAtPoint, GridDataRowElement) If dataRowElement IsNot Nothing AndAlso (Not Me.GridViewElement.IsInEditMode) Then Dim dragDropService As RadGridViewDragDropService = Me.GridViewElement.GetService(Of RadGridViewDragDropService)() dragDropService.Start(dataRowElement) Return True End If End If Return result End FunctionEnd ClassYou need to replace the default behavior with its extended version:
Me.radGridView1.GridBehavior = New MyGridBehavior()Kind regards,
Svett
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items