This is a migrated thread and some comments may be shown as answers.

Drag from RadGridView, Drop in ScheduleView

16 Answers 370 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
samy
Top achievements
Rank 1
samy asked on 28 Sep 2011, 01:17 PM
I'm trying to setup the following using Q2 2011 trial version of Telerik:
I have a radgridview that contains items of class A (not deriving from appointment). I want to be able to drag one row at a time into a scheduleview control where it will turn into an appointment at the desired location.
I tried following the explanations on the pinned thread in this forum but i'm hitting the following problems:
- i can't find a DragDropBehavior class, only a DragDropBehavior<T, ST> and the documentation doesn't give any indication about what classes this DragDropBehavior should work with
- i tried finding the ListBoxDragDropBehavior class to follow the example that is said to "[snip] provides drag-drop capabilities for standard ListBox controls" in the doc but i can't find it in the classes

Are there pointers about implementing drag from arbitrary controls bound to arbitrary classes and drop to the ScheduleView to create appointments?

16 Answers, 1 is accepted

Sort by
0
samy
Top achievements
Rank 1
answered on 29 Sep 2011, 09:53 AM
I've updated to the latest version of the controls (2011.2.920.1040), and i'm having problems following the recommended way of managing drag and drop.
Since i wanted to drag from a gridview bound to arbitrary entities (not appointments) into a schedule view, i decided to create a GridViewDragDrop

public class GridViewDragDrop: DragDrop<GridViewDragDropHelper, GridViewDragDropBehavior, GridViewDragDropState>
    {


However, when i try to create the GridViewDragDropHelper, i can't go any further since it must implement an internal abstract method, GetDraggedItems. Since i obviously can't plug in the Telerik namespace, i'm stuck. Apart from you changing the method signature, what's the way of handling this? Should i try another/older way of managing the drag and drop between these two controls?
0
Valeri Hristov
Telerik team
answered on 29 Sep 2011, 01:39 PM
Hello Samy,

We are currently working on a RadGridView drag-drop behavior, that most probably will be available in the internal build from the second week of October. I am afraid that currently you cannot create a custom drag-drop behavior based on our base classes. We will do our best to open the API with the Q3 2011 release in November.

Best wishes,
Valeri Hristov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Christian
Top achievements
Rank 1
answered on 11 Nov 2011, 10:11 AM
Anything new for the RadGridView Drag&Drop Behaviour? Is a sample availible?

Regards,Chris
0
Valeri Hristov
Telerik team
answered on 11 Nov 2011, 11:50 AM
Hello Christian,

The DragDropBehavior for RadGridView will not be built-in even with the Q3 release, but the prototype version is available as a sample (attached). If you don't want to do something more complex than drag grid rows to other controls or just reorder rows, the sample will be enough and you don't have to understand the classes in the GridView folder, which are fairly simple, though. We are open for feedback, so if you have suggestions or you find something that does not work as expected, please drop us a line, we will appreciate it.

You need to use the latest internal build of Q2 2011 in order to compile the application.

Regards,
Valeri Hristov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Pete
Top achievements
Rank 1
answered on 18 Jan 2012, 12:40 PM
How can I change the dragged visual cue for the dragged row?
In the previous versions this was done by setting the dragcue property on the DragDropQueryEventArgs:

private static void OnDragQuery(object sender, DragDropQueryEventArgs e)
{
    if (e.Options.Status == DragStatus.DragQuery)
    {
        if (e.Options.DragCue == null)
        {
            var sourceControl = e.Options.Source;
            var viewModel = (sourceControl.DataContext as MyViewModel);
            if (viewModel == null)
            {
                return;
            }
 
            var customAppointment = (CustomAppointment)viewModel.SelectedVisit;
            var dragCue = new DragVisualCue();
            dragCue.Height = 25;
            dragCue.Width = 100;
            dragCue.Template = (ControlTemplate)Application.Current.Resources["VisitDragCue"];
            dragCue.DataContext = sourceControl.DataContext;
            e.Options.DragCue = dragCue;
            RadDragAndDropManager.DragCueOffset = GetEffectiveDragOffset(e.Options);
 
            e.Options.Payload = new ScheduleViewDragDropPayload(viewModel.Visits, new List<IOccurrence> { viewModel.SelectedVisit });
        }
    }
    else if (e.Options.Status == DragStatus.DragCancel || e.Options.Status == DragStatus.DragComplete)
    {
        RadDragAndDropManager.DragCueOffset = new Point();
    }
 
    e.QueryResult = true;
    e.Handled = true;
}
0
Valeri Hristov
Telerik team
answered on 18 Jan 2012, 01:13 PM
Hi Pete,

RadGridView has built-in drag-drop provider from Q3 2011 SP1 (2011.3.1220). I would advise using the built-in functionality instead of the attached sample if you could upgrade. Note that the classes are not mapped to the telerik URI namespace yet and you should add a full xmlns declaration to the Telerik.Windows.DragDrop.Behaviors namespace in Telerik.Windows.Controls.GridView assembly.

The drag visual is customized using a DragVisualProvider. We have a couple of standard implementations: Default (shows a small summary element), Empty (only the mouse cursors are changed), Screenshot (makes a skreenshot of the dragged objects) that can be used like this:
http://www.telerik.com/help/silverlight/dragdropmanager-behaviors-customizingdragvisual.html

You could also create a special provider that returns a visual of your choice by implementing IDragVisualProvider in a class. I don't have an example and it should be straight-forward implementation, but if you have questions, please don't hesitate to ask.

Greetings,
Valeri Hristov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Pete
Top achievements
Rank 1
answered on 18 Jan 2012, 01:30 PM
I am using 2011.3.1220.1040 (and upgraded the demo app to this).
Could you explain how to use the built-in functionality please as I have tried removing the custom behavior from the demo app but it doesn't work.

<telerik:RadGridView
    telerik:DragDropManager.AllowDrag="True"
    ItemsSource="{Binding Appointments1}"
    SelectionMode="Single" >
 
    <!--<telerik:RadGridView.RowStyle>
        <Style TargetType="telerik:GridViewRow">
            <Setter Property="drag:DragDropManager.AllowDrag" Value="True" />
        </Style>
    </telerik:RadGridView.RowStyle>-->
 
    <!--
        <gridDrag:GridViewDragDrop.Behavior>
            <gridDrag:GridViewDragDropBehavior />
        </gridDrag:GridViewDragDrop.Behavior>
    -->
 
    <gridDrag:GridViewDragDrop.DataConverter>
        <local:DataConverterAppointments />
    </gridDrag:GridViewDragDrop.DataConverter>
 
    <gridDrag:GridViewDragDrop.DragVisualProvider>
        <dragDropBehaviors:ScreenshotDragVisualProvider />
    </gridDrag:GridViewDragDrop.DragVisualProvider>
 
</telerik:RadGridView>
0
Tsvyatko
Telerik team
answered on 19 Jan 2012, 02:04 PM
Hi,

 I have prepared sample project that illustrate how to use the build-in behaviors. In their nature they similar to the cusom ones from the project. You can still inherit or replace the visual provider to provide your own as described in the previopus post.

Please, have a look at the sample and let us know if you have any further questions.

All the best,
Tsvyatko
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Yonggu Kang
Top achievements
Rank 1
Iron
answered on 03 Apr 2012, 08:35 PM
Hi telerik,

I tried with your attached sample to drag from RadGridView and drop into radscheduledview
in SL5 with latest RadControl,but without sucecss.
Your attached sample app shows wpf version but broken for SL version,however I placed
all help classes as shown in sample project but dragging is not shown at all.
Could you pls provide another SL5 sample project ?

Thank you in advance.
Kang
0
Ivo
Telerik team
answered on 06 Apr 2012, 12:27 PM
Hi Kang,

You can find the example Valeri Hristov provided earlier updated for Silverlight 5.

All the best, Ivo
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
V
Top achievements
Rank 1
answered on 26 Sep 2012, 03:44 PM
In the example provided, RadgridView and RadScheduleView both uses Appointment as datasources.
For my project, radgridview is bound to custom business object. During drag and drop operation, based on the values in the custome business object, like to validate whether drop can be allowed. If allowed, like to build appointment object because the dragged object is not of appointment Type.

In  the ConvertDraggedData, method in ScheduleViewDragDropBehavior class, can I create new appointment object and return?
I tried, but it is not working.
0
Yana
Telerik team
answered on 01 Oct 2012, 01:19 PM
Hello,

I have attached an example showing how to implement drag and drop in both directions and with different datasources for RadGridView and RadScheduleView. You can use it as a base and override CanDrop method to implement the custom logic.

Hope this helps.

Greetings,
Yana
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

0
V
Top achievements
Rank 1
answered on 09 Oct 2012, 04:57 PM
After an Item is dragged from RadGridView to ScheduleView, dragged item is removed from source list. How can I stop it?
0
Yana
Telerik team
answered on 10 Oct 2012, 07:12 AM
Hello,

The item is removed from the GridView in DragDropCompleted event, so in order to change this behavior, you just need to override DragDropCompleted with empty definition:

namespace Telerik.Windows.Controls.GridView
{
    /// <summary>
    ///
    /// </summary>
    public class GridViewDragDropBehavior : DragDropBehavior<Telerik.Windows.DragDrop.Behaviors.DragDropState>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="GridViewDragDropBehavior"/> class.
        /// </summary>
        public GridViewDragDropBehavior()
        {
 
        }
 
        public override void DragDropCompleted(Windows.DragDrop.Behaviors.DragDropState state)
        {
            //base.DragDropCompleted(state);
        }
    }
}


Greetings,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
V
Top achievements
Rank 1
answered on 05 Dec 2012, 08:06 PM
Thanks that worked.
0
V
Top achievements
Rank 1
answered on 08 Dec 2012, 03:03 PM
Scenario:

I am dragging items from radgridview to radscheduleview. In the canDrop event, was making a synchronous database call to save the changes to the database; This database call is taking around 5 to 8 seconds; because of this, can drop event is getting raised multiple times.

SO I removed the database call and kept in appointment created event handler, again same issue. This event is getting raised again and again.

Please suggest the solution.
Tags
ScheduleView
Asked by
samy
Top achievements
Rank 1
Answers by
samy
Top achievements
Rank 1
Valeri Hristov
Telerik team
Christian
Top achievements
Rank 1
Pete
Top achievements
Rank 1
Tsvyatko
Telerik team
Yonggu Kang
Top achievements
Rank 1
Iron
Ivo
Telerik team
V
Top achievements
Rank 1
Yana
Telerik team
Share this question
or