Drag from RadGridView, Drop in ScheduleView

17 posts, 0 answers
  1. samy
    samy avatar
    25 posts
    Member since:
    Sep 2011

    Posted 28 Sep 2011 Link to this post

    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?
  2. samy
    samy avatar
    25 posts
    Member since:
    Sep 2011

    Posted 29 Sep 2011 Link to this post

    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?
  3. DevCraft banner
  4. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 29 Sep 2011 Link to this post

    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 >>

  5. Christian
    Christian avatar
    4 posts
    Member since:
    May 2011

    Posted 11 Nov 2011 Link to this post

    Anything new for the RadGridView Drag&Drop Behaviour? Is a sample availible?

    Regards,Chris
  6. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 11 Nov 2011 Link to this post

    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 >>

  7. Pete
    Pete avatar
    67 posts
    Member since:
    Sep 2012

    Posted 18 Jan 2012 Link to this post

    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;
    }
  8. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 18 Jan 2012 Link to this post

    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 >>

  9. Pete
    Pete avatar
    67 posts
    Member since:
    Sep 2012

    Posted 18 Jan 2012 Link to this post

    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>
  10. Tsvyatko
    Admin
    Tsvyatko avatar
    832 posts

    Posted 19 Jan 2012 Link to this post

    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 >>

  11. YongKoo Kang
    YongKoo Kang avatar
    101 posts
    Member since:
    Jan 2010

    Posted 03 Apr 2012 Link to this post

    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
  12. Ivo
    Admin
    Ivo avatar
    390 posts

    Posted 06 Apr 2012 Link to this post

    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 >>

  13. V
    V avatar
    8 posts
    Member since:
    Oct 2012

    Posted 26 Sep 2012 Link to this post

    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.
  14. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 01 Oct 2012 Link to this post

    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.

  15. V
    V avatar
    8 posts
    Member since:
    Oct 2012

    Posted 09 Oct 2012 Link to this post

    After an Item is dragged from RadGridView to ScheduleView, dragged item is removed from source list. How can I stop it?
  16. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 10 Oct 2012 Link to this post

    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.

  17. V
    V avatar
    8 posts
    Member since:
    Oct 2012

    Posted 05 Dec 2012 Link to this post

    Thanks that worked.
  18. V
    V avatar
    8 posts
    Member since:
    Oct 2012

    Posted 08 Dec 2012 Link to this post

    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.
Back to Top
DevCraft banner