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

[Solved] Load on Demand with Drop between nodes

7 Answers 125 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Frank Michael
Top achievements
Rank 1
Frank Michael asked on 05 Nov 2010, 03:57 PM
When I have a Tree with LoD and Drop between nodes, I can not really predict, what happens to the dropped node.
The MVC gets the node over the drop place as the new super node, and reassigns, but the control leaves it on the same level.

Before drop:

Node 1
Node 2
Node 3
Node 4

If I drop Node 4 between Node 1 and Node 2, the MVC Action gets Node 1 as new Supernode, and reassigns it.
However the Control (sometimes?) shows:

Node 1
Node 4
Node 2
Node 3

If I refresh the page it is

Node 1
   Node 4
Node 2
Node 3

Sometimes.

Sometimes I think I found it under Node 2 or under some other node. It is hard to reproduce.

I remember, that I often do not find the node where I expected it.

So - what is the expected behavior?

And how can I determine if the node has been dropped on another node or between two other nodes?

And maybe I can switch off the dropping in between nodes altogether and only use the dropping on nodes? Then I would have no problem. Because semantically It does not make any sense to me anyway, because I do not have a specific order of nodes anyway - not a persistent order of nodes. So if there is an order, it is only temporary anyways.

 

7 Answers, 1 is accepted

Sort by
0
Frank Michael
Top achievements
Rank 1
answered on 11 Nov 2010, 11:10 AM
Is there anybody? Is my question too difficult? Not good explained?
0
Atanas Korchev
Telerik team
answered on 11 Nov 2010, 11:37 AM
Hi Frank Michael ,

We need a sample project demonstrating the unwanted behavior.

Greetings,
Atanas Korchev
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
Frank Michael
Top achievements
Rank 1
answered on 11 Nov 2010, 11:40 AM
In this case it is more efficient, if you explain the expected behavior or if you tell me, where I can find the information.
Then I can debug myself. That is more effective.
0
Atanas Korchev
Telerik team
answered on 11 Nov 2010, 11:41 AM
Hi Frank Michael ,

 What behavior do you need explained? What is your scenario? What is your requirement?

Regards,
Atanas Korchev
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
Frank Michael
Top achievements
Rank 1
answered on 11 Nov 2010, 11:47 AM
I try to make it as clear as possible:

What happens, if I drop a node *in-between* two other nodes. What is the expected behavior?

Is it possible to disable the "dropping in-between" and only allow the dropping "on" another node?
0
Atanas Korchev
Telerik team
answered on 11 Nov 2010, 01:24 PM
Hi Frank Michael ,

When you drop a node between other nodes the node is inserted at that position. The node drop event tells the drop position what has been dropped and where. You can check the client-events demo.

Currently the drag and drop between nodes cannot be disabled which I consider an omission. We will try to implement that for the next official release (the first service pack of the Q3 release). Currently there is no workaround except modifying the treeview source code.

Atanas Korchev
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
andy
Top achievements
Rank 1
answered on 23 Feb 2011, 05:12 PM
Hi Telerik,

I am having an issue which is in line with this current thread.

We persist the order of nodes (within a common parent) in our database. We would like the behavior to be: 1) when you drag and drop a node between 2 other nodes it is inserted between those nodes 2) When you drag a node over another node and drop it, the source node will be a child of the target node.

Here is what happens: When we drag and drop a node between 2 nodes and I get the parent of the destination node, it is giving me the parent of the node right next to it (see code that I am using below). Thus when I pass this information up to the controller, the controller thinks that the user is reparenting a node. When the user drags a node over a node and drops, this works beautifully.

My 2 Questions Are:
1) How can I detect when the user is dropping between 2 nodes versus dropping over a node?
2) How can I read the data of the two nodes that it is being inserted next to so that I can reset the position flags that we have stored?

Thank You In Advance,
Andy

<%

 

= Html.Telerik().TreeView()

 

 

.Name(

 

"TaskTreeView")

 

 

.ExpandAll(

 

true)

 

 

.DragAndDrop(

 

true)

 

 

.HtmlAttributes(

 

new { @class = "t-group" })

 

 

.BindTo(Model.Tasks, mappings =>

 

{

 

mappings.For<DataNet.WebUI.ViewModels.

 

TaskViewModel>(binding =>

 

 

binding.ItemDataBound((item, task) =>

 

{

 

item.Text = task.Name;

 

item.Value = task.Id.ToString();

 

})

 

.Children(task => task.ChildTasks));

 

})

 

.ClientEvents(e => e.OnSelect(

 

"TaskTreeView_onSelect"))

 

 

.ClientEvents(e => e.OnNodeDropped(

 

"TaskTreeView_onDropped"))

 

 

%>



 

 

function TaskTreeView_onDropped(e) {

 

 

 

 

var treeView = $('#TaskTreeView').data('tTreeView');

 

 

 

 

var selectedValue = treeView.getItemValue(e.item);
// TELERIK PEOPLE - Below returns parent of neighbor node, even when dropping between nodes.

 

 

 

 

var parentValue = treeView.getItemValue(e.destinationItem);

 

$.get(

 

'<%=Url.Action("MoveTask", "Project") %>',

 

 

{

 

sourceId: selectedValue,

 

destinationId: parentValue,

 

requestTime: Date.valueOf()

 

},

 

 

 

function (result) { //JavaScript callback executed when the ajax request finishes

 

$(

 

'#TaskDetailsDiv').html(result); // update the DIV which contains the grid

 

});

}

Tags
TreeView
Asked by
Frank Michael
Top achievements
Rank 1
Answers by
Frank Michael
Top achievements
Rank 1
Atanas Korchev
Telerik team
andy
Top achievements
Rank 1
Share this question
or