I'm migrating an application from the old MVC extensions, to KendoUI.
I finally managed to populate my treeview, and get the ID on selection. I now need to replicate the drag and drop functionality, which limits what items can be dragged where.
Essentially I need to restrict dragging, so that items can only be dragged into items of the level above
i.e. A fourth level item can only be dragged to third level items etc..
In my original application (using the MVC extensions, I did this by using the onNodeDragging event - which I know has been replaced by the Drag event.
The code was:-
I've changed the setStatusClass line to
But I'm at a loss on how to alter the isDropAllowed function to work with the KendoTreeView.
Thanks
I finally managed to populate my treeview, and get the ID on selection. I now need to replicate the drag and drop functionality, which limits what items can be dragged where.
Essentially I need to restrict dragging, so that items can only be dragged into items of the level above
i.e. A fourth level item can only be dragged to third level items etc..
In my original application (using the MVC extensions, I did this by using the onNodeDragging event - which I know has been replaced by the Drag event.
The code was:-
function
onNodeDragging(e) {
if
(!isDropAllowed(e))
e.setStatusClass(
't-denied'
);
}
function
isDropAllowed(e)
{
var
$dropTarget = $(e.dropTarget);
var
hoveredItem = $dropTarget.closest(
'.t-top,.t-mid,.t-bot'
);
if
(hoveredItem.length > 0) {
var
itemHeight = hoveredItem.outerHeight();
var
itemTop = hoveredItem.offset().top;
var
itemContent = $dropTarget.closest(
'.t-in'
);
var
delta = itemHeight / (itemContent.length > 0 ? 4 : 2);
var
insertOnTop = e.pageY < (itemTop + delta);
var
insertOnBottom = (itemTop + itemHeight - delta) < e.pageY;
var
addChild = itemContent.length > 0 && !insertOnTop && !insertOnBottom;
if
(addChild)
return
$dropTarget.parents(
'.t-item'
).length == itemLevel;
else
return
$dropTarget.parents(
'.t-item'
).length == itemLevel + 1;
}
return
false
;
}
I've changed the setStatusClass line to
e.setStatusClass(
"k-denied"
);
But I'm at a loss on how to alter the isDropAllowed function to work with the KendoTreeView.
Thanks