Manage unauthorized drop

7 posts, 0 answers
  1. BENOIT CHEVALIER
    BENOIT CHEVALIER avatar
    22 posts
    Member since:
    Nov 2009

    Posted 12 Dec 2011 Link to this post

    [Q3 20011]
    Hi I'm trying to implement a drag and drop functionality between a treelistview and a radgridview
    No problem here

    Where I get stuck is when I'm passing over other control, than the treelistview or radgridview.
    I just want for "IsDropPossible" to be false when I'm not over a manage control.
    I can't found a simple way to do it without adding each control to RadDragAndDropManager.AddDropInfoHandler

    Any advice ?

    Thanks
  2. Nick
    Admin
    Nick avatar
    593 posts

    Posted 12 Dec 2011 Link to this post

    Hi Benoit Chevalier,

    You can use the DragQuery event to validate the drop. 
    Subscribe to it by 
    RadDragAndDropManager.AddDragQueryHandler(this, OnDragQuery);

    You can check the current destination in the handler by accessing eventArgs.Options.Destination, and if it doesn't suit your needs set the eventArgs.QueryResult to false.

    Hope this helps!

    Best wishes,
    Nik
    the Telerik team

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

  3. DevCraft banner
  4. BENOIT CHEVALIER
    BENOIT CHEVALIER avatar
    22 posts
    Member since:
    Nov 2009

    Posted 12 Dec 2011 Link to this post

    Hi the event is not always call
    Odly it's called when starting a drag from the radgridview and not from the treelistview

    But this is still not resolving my problem, even for the radgridview drag, as soon as I got out of my "dropable zone" the event is not called anymore, so i can't set the query result to false.

    I may be doing something wrong, if you could give me a sample project, would really appreciate it

    Thanks in advance.
  5. Nick
    Admin
    Nick avatar
    593 posts

    Posted 13 Dec 2011 Link to this post

    Hi Benoit Chevalier,

    You are absolutely right. The proper place to put such a logic is in the DropQuery handler.
    I am attaching a simple application demonstrating a simple scenario on how to accomplish a similar behavior.
    You can see that in the DropQuery handler I am checking the name of the destination control, and if it isn't what I expect I simply set the query result to false. Of course you can do a lot more than that, and modify it in a way that suits the requirements that you have.

    I hope this helps!

    Best wishes,
    Nik
    the Telerik team

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

  6. BENOIT CHEVALIER
    BENOIT CHEVALIER avatar
    22 posts
    Member since:
    Nov 2009

    Posted 13 Dec 2011 Link to this post

    Tanks for your answer, but your example is confirming my problem or I may not be clear about what I'm looking for:

    I wish for a visual result to show users if they can drop a row in an area (gridview) or not (listbox, grid, button, ect)
    if you modifiy your xaml like this

    <StackPanel Orientation="Horizontal">
                <telerik:RadGridView x:Name="gridView"
                                     Width="200"
                                     telerik:RadDragAndDropManager.AllowDrop="True"
                                     RowStyle="{StaticResource draggableRowStyle}"/>
                <telerik:RadTreeListView x:Name="treeView"
                                         Width="0"
                                         telerik:RadDragAndDropManager.AllowDrop="True"
                                         RowStyle="{StaticResource draggableTreeRowStyle}"/>
                <ListBox Width="200"/>
                <telerik:RadTreeListView x:Name="treeView1"
                                         Width="200"
                                         telerik:RadDragAndDropManager.AllowDrop="True"
                                         RowStyle="{StaticResource draggableRowStyle}"/>
            </StackPanel>

    I just "replace" the "treeView" by a listbox, simple regular control. When you drag over the listbox, no event => How do i set the query result to false (btw don't know why, but in your exmemple, i can't have a tooltip icon sign that show if it's dropable or not)

    Do I really need to add a "telerik:RadDragAndDropManager.AllowDrop="True"" on every controls (a lot!)  of my silverlight application?

    Thanks
  7. Nick
    Admin
    Nick avatar
    593 posts

    Posted 16 Dec 2011 Link to this post

    Hello Benoit Chevalier,

    Unfortunately if you want the events to raise, you will have to add "telerik:RadDragAndDropManager.AllowDrop="True"", either in each control definition, or in an implicit style. Other than that, you cannot drop on a control with a AllowDrop = "True". As for the visual indications, you can use the DragCue functionality to obtain the desired behavior. 

    Hope you find this information helpful! 

    Regards,
    Nik
    the Telerik team

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

  8. BENOIT CHEVALIER
    BENOIT CHEVALIER avatar
    22 posts
    Member since:
    Nov 2009

    Posted 16 Dec 2011 Link to this post

    My bad, I am the one that was missing something.
    Just in case someone do have the same problem :

    In the DropInfo I'm checking if the "droping zone" is OK or NOT but I wasn't taking in acount the e.Options.Status

    So I just added a check on e.Options.Status  != DragStatus.DropImpossible before touching any dragcue
Back to Top
DevCraft banner