Telerik RadTreeView 拖放节点

发布于 2024-09-06 13:10:39 字数 689 浏览 8 评论 0原文

将 RadTreeView 节点拖动到另一个节点时覆盖默认文本并创建“视觉提示”的最佳方法是什么? 我首先是:

...
telerik:RadTreeView OnClientNodeDragging="ClientNodeDragging"
...

function ClientNodeDragging(sender, args)
{
    if (!visualClue)
    {
        visualClue = createVisualClue();
        document.body.insertBefore(visualClue, document.body.firstChild);
    }

    visualClue.style.left = args._domEvent.screenX + "px";
    visualClue.style.top = args._domEvent.screenY + "px";
}

如何在屏幕上显示文本?

目前,它位于可拖动节点下方约 20 px,并且现有的拖动文本 (RadTreeView) 仍然显示(显示节点文本的名称 - 我希望将其删除或覆盖/隐藏)。

更新 好的,我现在已经使用了 args._domEvent.clientX 和 .clientY 。关闭,但现在我需要一种删除 RadTreevIew 自己的文本的方法。

What's the best way to override the default text and create a "Visual Cue" when Dragging a RadTreeView Node to another.
I've started by:

...
telerik:RadTreeView OnClientNodeDragging="ClientNodeDragging"
...

function ClientNodeDragging(sender, args)
{
    if (!visualClue)
    {
        visualClue = createVisualClue();
        document.body.insertBefore(visualClue, document.body.firstChild);
    }

    visualClue.style.left = args._domEvent.screenX + "px";
    visualClue.style.top = args._domEvent.screenY + "px";
}

Is the way to go about displaying the text on screen?

At the moment it's approx 20 px below the draggable node and the existing drag text (RadTreeView) still displays (displays the name of the node text - I want it removed or overridden/hidden).

UPDATE
OK I've used args._domEvent.clientX and .clientY now. Close, but now I need a way of removing the RadTreevIew's own text.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如果没结果 2024-09-13 13:10:39

我设法使用 IE 的调试器(也可以使用任何其他调试器)将其解决,并注意到发件人有这个 _draggingClue - BINGO!
所以剩下的就是像这样设计它:

function ClientNodeDragging(sender, args)
{
    var node = args.get_node();
    if (node.get_level() != 0)
    {
        var dom = args.get_domEvent();
        var div = sender._draggingClue;
        var moveCopyText = "Copy";
        var hidden = document.getElementById("<%= MoveCopyHiddenField.ClientID %>");

        if (dom.shiftKey) {
            hidden.value = "true";
            moveCopy = true;
        }
        else if (dom.ctrlKey) {
            hidden.value = "false";
            moveCopy = false;
        }
        else {
            hidden.value = "true";
            moveCopy = true;
        }

        if(moveCopy)
            moveCopyText = "Move";
        else
            moveCopyText = "Copy";

        div.className = "DragFile";
        div.style.height = '15px';
        div.style.paddingTop = '3px';
        div.innerHTML = moveCopyText + " " + node.get_text();
    }
}

希望这可以帮助某人,也许我自己在这么多年的时间里;)

I Managed to sort it out by using IE's debugger (could have used any other debugger) and noticed the sender has this _draggingClue - BINGO!!
So all that was left was to style it like this:

function ClientNodeDragging(sender, args)
{
    var node = args.get_node();
    if (node.get_level() != 0)
    {
        var dom = args.get_domEvent();
        var div = sender._draggingClue;
        var moveCopyText = "Copy";
        var hidden = document.getElementById("<%= MoveCopyHiddenField.ClientID %>");

        if (dom.shiftKey) {
            hidden.value = "true";
            moveCopy = true;
        }
        else if (dom.ctrlKey) {
            hidden.value = "false";
            moveCopy = false;
        }
        else {
            hidden.value = "true";
            moveCopy = true;
        }

        if(moveCopy)
            moveCopyText = "Move";
        else
            moveCopyText = "Copy";

        div.className = "DragFile";
        div.style.height = '15px';
        div.style.paddingTop = '3px';
        div.innerHTML = moveCopyText + " " + node.get_text();
    }
}

Hope this helps someone and perhaps myself in so many years time ;)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文