/    Sign up×
Community /Pin to ProfileBookmark

TreeView dragging and dropping

Hi ?

I am having a bit of an issue with the TreeView draggable nodes.
(This is the telerik MVC treeview control, but the problem is a javascript/jquery one)

I can drag and drop the different nodes where I please.
I don’t want to be able to drag anything inline with the “Home” category, but I do want to be able to drag it to be the child…
I added this code:

[CODE]
function onNodeDrop(e) {
var dropContainer = $(e.dropTarget).closest(‘.drop-container’);
var treeview = $(‘#TreeView’).data(‘tTreeView’);
var parentId = treeview.getItemValue(e.destinationItem);
var firstNodeElement = treeview.getItemValue($(“li:first”, treeview.element)[0]);
var nodeText = treeview.getItemText(e.item);
if (parentId == firstNodeElement) {
e.preventDefault();
}
if (dropContainer.length > 0 && dropContainer[0].innerHTML.indexOf(nodeText) == -1) {
$(‘<div><strong>’ + nodeText + ‘</strong></div>’)
.hide().appendTo(dropContainer).slideDown(‘fast’);
e.preventDefault();
}
}
[/CODE]

which stops me putting any nodes next to the “Home” node, but it also stops me being able to add any children.
Could someone please let me know how to add child nodes to the “Home” node, but disable dragging nodes to it’s level?

Cheers,
/Jaymie

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @r3plica spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...