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
We need a sample project demonstrating the unwanted behavior.
Greetings,Atanas Korchev
the Telerik team
Then I can debug myself. That is more effective.
What behavior do you need explained? What is your scenario? What is your requirement?
Regards,Atanas Korchev
the Telerik team
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?
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.
the Telerik team
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
});
}