[CLOSED] Prevent treenodes from being dragged

  1. #1

    [CLOSED] Prevent treenodes from being dragged

    Is there a way to prevent treenodes from being dragged based on an attribute on the treenode? This needs to be done on clientside. I can't find a BeforeDrag or StartDrag event on TreePanel or TreeNode.
    Last edited by Daniil; Nov 18, 2011 at 7:04 AM. Reason: [CLOSED]
  2. #2
  3. #3
    I found a solution here:

    http://www.sencha.com/forum/showthre...-drag-and-drop

    to override the OnBeforeDrag event in the TreeDragZone. I know about those properties but I wanted to evaluate whether a treenode is draggable at 'real' time
  4. #4
    Hi,

    Please note that you can override onBeforeDrag in TreePanel's DragConfig.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:TreePanel 
                runat="server" 
                AutoHeight="true" 
                RootVisible="false"
                EnableDD="true">
                <Root>
                    <ext:TreeNode>
                        <Nodes>
                            <ext:TreeNode Text="I'm not draggable">
                                <CustomAttributes>
                                    <ext:ConfigItem Name="myAllowDrag" Value="false" />
                                </CustomAttributes>
                            </ext:TreeNode>
                            <ext:TreeNode Text="I'm draggable" >
                                <CustomAttributes>
                                    <ext:ConfigItem Name="myAllowDrag" Value="true" />
                                </CustomAttributes>
                            </ext:TreeNode>
                            <ext:TreeNode Text="I'm not draggable">
                                <CustomAttributes>
                                    <ext:ConfigItem Name="myAllowDrag" Value="false" />
                                </CustomAttributes>
                            </ext:TreeNode>
                        </Nodes>
                    </ext:TreeNode>
                </Root>
                <DragConfig runat="server">
                    <OnBeforeDrag Handler="var n = data.node;
                                           return n && n.draggable && !n.disabled && n.attributes.myAllowDrag;" />
                </DragConfig>
            </ext:TreePanel>
        </form>
    </body>
    </html>

Similar Threads

  1. [CLOSED] [1.0] Restrict rows to be Dragged and Dropped
    By MP in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Sep 29, 2010, 1:22 PM
  2. Replies: 1
    Last Post: Aug 10, 2010, 2:05 PM
  3. [CLOSED] [1.0] Add treenodes during DirectEvent
    By wazige in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: May 12, 2010, 5:07 AM
  4. [CLOSED] Generating TreeNodes in Codebehind
    By macap in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Mar 03, 2010, 5:22 AM
  5. Add Parameters to TreePanel treenodes
    By andrlar in forum 1.x Help
    Replies: 2
    Last Post: May 15, 2009, 4:01 AM

Posting Permissions