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

Manage unauthorized drop

6 Answers 82 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
BENOIT CHEVALIER
Top achievements
Rank 1
BENOIT CHEVALIER asked on 12 Dec 2011, 10:36 AM
[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

6 Answers, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 12 Dec 2011, 03:39 PM
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 >>

0
BENOIT CHEVALIER
Top achievements
Rank 1
answered on 12 Dec 2011, 06:08 PM
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.
0
Nick
Telerik team
answered on 13 Dec 2011, 10:29 AM
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 >>

0
BENOIT CHEVALIER
Top achievements
Rank 1
answered on 13 Dec 2011, 11:13 AM
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
0
Nick
Telerik team
answered on 16 Dec 2011, 10:22 AM
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 >>

0
BENOIT CHEVALIER
Top achievements
Rank 1
answered on 16 Dec 2011, 10:48 AM
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
Tags
TreeListView
Asked by
BENOIT CHEVALIER
Top achievements
Rank 1
Answers by
Nick
Telerik team
BENOIT CHEVALIER
Top achievements
Rank 1
Share this question
or