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

Tell users why they cannot drop.

4 Answers 72 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Meerkat
Top achievements
Rank 1
Meerkat asked on 09 Aug 2010, 09:32 AM

Hello,
Can someone please tell me the best way to indicate to a user why he cannot drop into a node.

For the sake of a contrived example, lets say there are three nodes

    Smith
    Brown
    Bloggs

I do not want to allow the Brown or Boggs nodes to be dropped into Smith, because Smith does not begin with a 'B'.

I believe I know how to actually prevent the drop using DropQueryEvent but what would be the best way of indicating to the user the reason he cannot do the drop.

I am hoping there might be some sort of Tooltip thing but anything practical will do.

Many thanks.

4 Answers, 1 is accepted

Sort by
0
Miroslav
Telerik team
answered on 11 Aug 2010, 06:10 PM
Hello Meerkat,

Yes, with the DragQuery event you can say that a drop should not be possible. Either there or in the DropInfo event with status "DropImpossible" you can access the e.Options.DragCue object.

In the case of the TreeView this object is the TreeViewDragCue which is an ItemsCotnrol that has the DragTooltipContent/Template and DragTooltipAction/Template are the properties that are looking for. They normally contain the current drop target and the drop action.

Regards,
Miroslav
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
Meerkat
Top achievements
Rank 1
answered on 12 Aug 2010, 09:49 AM
Hello Miroslav,

I tried unsuccessfully to find a clue in your documention about how your suggestions might be used to display a tooltip that said "You Cannot drop here because Smith does not begin with B", when the mouse hovered over Smith,

I fully appreciate that as Telerik  gets bigger it becomes harder to find the time to keep the documentation complete and up to date and also to provide the excellent service of the past.

Nevertheless, I will definitely be back searching for your advice in the future :-)

Many thanks anyway for your help on my current problem..
 
Regards

Meerkat


0
Accepted
Miroslav
Telerik team
answered on 17 Aug 2010, 10:50 AM
Hi Meerkat,

Indeed, this example was not available in the documentation. It will be added with a coming update.

I could not make out if you have managed to use these properties - I am attaching a  sample project where this is shown.

We have always tried to listen and I can only urge you to point out things that can be improved.

Thanks for the feedback!

Best wishes,
Miroslav
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
Meerkat
Top achievements
Rank 1
answered on 17 Aug 2010, 11:50 AM
Many thanks for the example Miroslav
I needed to make one or two minor changes to get things to work as in my case the tree is databound, but things seem to be working fine now. Smashing !

Regards,

Meerkat.


private void OnDropQuery(object sender, DragDropQueryEventArgs e)
{
  var destination = e.Options.Destination as RadTreeViewItem;
  var cue = e.Options.DragCue as TreeViewDragCue;
  
  // Do not allow dropping inside items which start with "B", only handle cases 
  // where a drop is currently allowed.
  
  TreeItem destItem = destination.Item as TreeItem;
  
  if (destination != null
    && e.Options.Status == DragStatus.DropDestinationQuery
    && e.QueryResult == true
    && destination.DropPosition == DropPosition.Inside
    && destItem.NodeText.StartsWith("B"))
  {
    // Denying a drop will set the cue.IsDropPossible = false
    e.QueryResult = false;
  
    // We only need to give a reason:
    cue.DragActionContent = "Cannot drop into Bs";
  }
}
Tags
TreeView
Asked by
Meerkat
Top achievements
Rank 1
Answers by
Miroslav
Telerik team
Meerkat
Top achievements
Rank 1
Share this question
or