binding a tree column value from the server during the drag and drop.

  1. #1

    binding a tree column value from the server during the drag and drop.

    I have 2 tree panels, I will be dragging a dropping value from one tree to another tree.
    The second tree will have multiple columns. The first column will have the data which is dragged from the source tree.

    Please have a look at the below image:

    Click image for larger version. 

Name:	illa.png 
Views:	147 
Size:	19.8 KB 
ID:	24435

    In the image above, Business Roles comes from the source tree that is bound to the first column of the destination tree.
    My requirement here is : I would want to send the 'Business Roles' to the server or database to fetch its 'Milestone Cat1' data and display it in the second column.

    Note : The above image is a morphed one to make understand my requirement.

    Please find the runnable test case for the same:

    <%@ Page Language="C#" %>
    
    <%@ Import Namespace="System.Collections.Generic" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                SiteMapNode siteNode = SiteMap.RootNode;
                Node node = this.CreateNodeWithOutChildren(siteNode);
                node.AllowDrag = true;
                node.Expanded = true;
                TreePanel1.Root.Add(node);
            }
        }
    
        //page tree node loader handler
        protected void LoadPages(object sender, NodeLoadEventArgs e)
        {
            if (!string.IsNullOrEmpty(e.NodeID))
            {
                SiteMapNode siteMapNode = SiteMap.Provider.FindSiteMapNodeFromKey(e.NodeID);
    
                if (siteMapNode == null)
                {
                    return;
                }
    
                SiteMapNodeCollection children = siteMapNode.ChildNodes;
    
                if (children != null && children.Count > 0)
                {
                    foreach (SiteMapNode mapNode in siteMapNode.ChildNodes)
                    {
                        e.Nodes.Add(this.CreateNodeWithOutChildren(mapNode));
                    }
                }
            }
        }
    
        //dynamic node creation
        private Node CreateNodeWithOutChildren(SiteMapNode siteMapNode)
        {
            Node treeNode;
    
            if (siteMapNode.ChildNodes != null && siteMapNode.ChildNodes.Count > 0)
            {
                treeNode = new Node();
            }
            else
            {
                treeNode = new Ext.Net.Node();
                treeNode.Leaf = true;
            }
    
            treeNode.NodeID = siteMapNode.Key;
            treeNode.Text = siteMapNode.Title;
            treeNode.Qtip = siteMapNode.Description;
    
            return treeNode;
        }
    
        [DirectMethod(ShowMask = true)]
        public void callMe(string abc)
        {
            string folderName = abc;
    
            string nodeId = "check";
            Node node = new Node()
            {
                NodeID = "xyz",
                Text = folderName,
                Expanded = false,
                EmptyChildren = true,
                Icon = Icon.Folder
            };
            //node.CustomAttributes.Add(new ConfigItem("task", folderName, ParameterMode.Value));
            //node.CustomAttributes.Add(new ConfigItem("duration", "", ParameterMode.Value));
            //node.CustomAttributes.Add(new ConfigItem("user", "", ParameterMode.Value));
    
            //TreeSelectionModel sm = TreePanel1.GetSelectionModel() as TreeSelectionModel;
            string SelectedNode = nodeId;
            //string childNode = string.Empty;
            //string parentName = folderName;
    
            //if (sm.SelectedNodes != null)
            //{
            //    SubmittedNode Subnode = sm.SelectedNodes[0];
            //    SelectedNode = Subnode.NodeID;
            //    parentName = Subnode.Text;
            //    childNode = folderName;
            //    // AddSubFolder(folderName, nodeId, SelectedNode);
            //}
            // else
            // {
            TreePanel2.GetNodeById(SelectedNode).AppendChild(node);
            // }            
    
        }
    
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head id="Head1" runat="server">
        <title>Drag and Drop betweens two TreePanels - Ext.NET Examples</title>
        <link href="/resources/css/examples.css" rel="stylesheet" />
        <style>
            .tree {
                float: left;
                margin: 20px;
                border: 1px solid #c3daf9;
            }
        </style>
     <ext:XScript ID="XScriptdd1" runat="server">
        <script type="text/javascript">
            var beforerecorddrop = function (node, data, overModel, dropPosition, dropFn) {
                // debugger;
    
                var draggedRecord = data.records[0].data
                var draggedNode = App.TreePanel1.store.getNodeById(draggedRecord.id);
                var srcTreeRootNode = App.TreePanel1.getRootNode();
    
                // Fill an array with the path (from leaf to root)
                var folderHierarchy = [];
                var parentNode = draggedNode.parentNode;
                while (parentNode != null && parentNode.id != srcTreeRootNode.id) {
                    folderHierarchy[folderHierarchy.length] = parentNode;
                    parentNode = parentNode.parentNode;
                }
                
                var curDestNode = overModel;
                if (curDestNode.isLeaf()) {
                    // Dropped on a leaf that is also root?
                    if (curDestNode.isRoot()) {
                        return false;
                    }
    
                    // Move one level upper, to an actual folder node.
                    curDestNode = curDestNode.parentNode;
                }
                
                // Walk from shallowest to deepest path nodes, creating them as necessary
                for (var i=folderHierarchy.length - 1; i >= 0; i--) {
                    var thisNode = folderHierarchy[i];
                    
                    // Check if the folder already exists
                    var parentExists = false;
                    for (var j in curDestNode.childNodes) {
                        if (curDestNode.childNodes[j].data.text == thisNode.data.text) {
                            parentExists = true;
                            break;
                        }
                    }
    
                    // If not, then make a copy of the node into the destination tree
                    if (!parentExists) {
                        curDestNode.appendChild(thisNode.copy());
                    }
    
                    // Get child node on dest tree
                    for (var j in curDestNode.childNodes) {
                        if (curDestNode.childNodes[j].data.text == thisNode.data.text) {
                            curDestNode = curDestNode.childNodes[j];
                            break;
                        }
                    }
                }
    
                // Drop a copy of the node in the deepest level of the structure created
                curDestNode.appendChild(draggedNode.copy());
    
                // Do not continue normal node drop operation.
                return false;
            };
    
          
    
            var beforenodedrop = function (node, data, overModel, dropPosition, dropFn) {
                // debugger;
                if (Ext.isArray(data.records)) {
                    var records = data.records,
                        rec;
    
                    data.records = [];
    
                    for (var i = 0; i < records.length; i++) {
                        rec = records[i];
    
                        data.records.push(this.store.createModel({
                            company: rec.get("text"),
                            price: rec.get("price"),
                            change: rec.get("change"),
                            pctChange: rec.get("pctChange"),
                            lastChange: rec.get("qtip")
                        }));
    
                        rec.remove(true);
                    }
    
                    return true;
                }
            };
    
            var nodeDragOver = function (targetNode, position, dragData) {
                //debugger;
                
                var rec = dragData.records[0],
                    isFirst = targetNode.isFirst(),
                    canDropFirst = rec.get('canDropOnFirst'),
                    canDropSecond = rec.get('canDropOnSecond');
                // alert(rec.parentNode.data.text);
                #{HdnFolderName}.setValue(rec.parentNode.data.text);
                return true;//isFirst ? canDropFirst : canDropSecond;
            };
        </script>
        </ext:XScript>
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:Hidden ID="HdnFolderName" runat="server" />
            <ext:ResourceManager ID="ResourceManager1" runat="server"/>
    
            <h1>Drag and Drop betweens two TreePanels</h1>
    
            <p>The TreePanels have a TreeSorter applied in "folderSort" mode.</p>
    
            <p>Both TreePanels are in "appendOnly" drop mode since they are sorted.</p>
    
            <p>Drag along the edge of the tree to trigger auto scrolling while performing a drag and drop.</p>
    
            <p>The data for this tree is asynchronously loaded with a TreeStore.</p>
    
            <div class="tree">
                <ext:TreePanel
                    ID="TreePanel1"
                    runat="server"
                    Border="false"
                    Height="300"
                    Width="250"
                    UseArrows="true"
                    Animate="true">
                    <Store>
                        <ext:TreeStore ID="TreeStore1"
                            runat="server"
                            OnReadData="LoadPages"
                            FolderSort="true">
                            <Proxy>
                                <ext:PageProxy />
                            </Proxy>
                            <Sorters>
                                <ext:DataSorter Property="text" />
                            </Sorters>
                        </ext:TreeStore>
                    </Store>
                    <View>
                        <ext:TreeView ID="TreeView1" runat="server">
                            <Plugins>
                                <ext:TreeViewDragDrop ID="TreeViewDragDrop1" runat="server" AppendOnly="true" />
                            </Plugins>                      
                        </ext:TreeView>
    
                    </View>
    
                </ext:TreePanel>
            </div>
    
            <div class="tree">
                <ext:TreePanel
                    ID="TreePanel2"
                    runat="server"
                    Height="300"
                    Width="250"
                    Border="false"
                    UseArrows="true"
                    AutoScroll="true">
    
                 
                    <View>
                        <ext:TreeView ID="TreeView2" runat="server">
                            <Plugins>
                                <ext:TreeViewDragDrop ID="TreeViewDragDrop2" runat="server" AppendOnly="true"   />
                            </Plugins>
                            <Listeners>
                                <BeforeDrop Fn="beforerecorddrop" />
                            </Listeners>
                        </ext:TreeView>
                    </View>
    
                    <Root>
                        <ext:Node Text="My Files" Icon="Folder" Expanded="true" NodeID="check" EmptyChildren="true" />
                    </Root>
                    <Listeners>
                        <NodeDragOver Fn="nodeDragOver" />
                    </Listeners>
                </ext:TreePanel>
            </div>
        </form>
    </body>
    </html>
    Let me know any other details is required.
  2. #2
    Hello @ArjunVasisht!

    I understand you want to pull the milestone information from the server but, if you can afford to have it on the left pannel (hidden) already, it would make it much easier, simpler and fast (as no server access would be necessary every drop).

    In your example, line 61, you map the site map's Description field into qtip. And it is never actually used. The fact is that this field is already carried away down to the second tree panel when you drop it. And you can just use it. Or have your web.sitemap have this information or, maybe better, do the database query during read data and preload the milestones for each node up front.

    I will explore this simpler case now.

    Simple Solution

    Just change your second Tree Panel into a Tree Grid! It is that simple!

    Here is the code for your second panel, you can just copy and paste it on your code (overwriting the second/right panel's code):
    <ext:TreePanel
        ID="TreePanel2"
        runat="server"
        Height="300"
        Width="250"
        Border="false"
        UseArrows="true"
        AutoScroll="true">
        <Fields>
            <ext:ModelField Name="text" />
            <ext:ModelField Name="qtip" />
        </Fields>
        <ColumnModel>
            <Columns>
                <ext:TreeColumn runat="server" Text="Folders / Programs" DataIndex="text" Flex="1" />
                <ext:Column runat="server" Text="Milestone Cat1" DataIndex="qtip" />
            </Columns>
        </ColumnModel>
        <View>
            <ext:TreeView ID="TreeView2" runat="server">
                <Plugins>
                    <ext:TreeViewDragDrop ID="TreeViewDragDrop2" runat="server" AppendOnly="true"   />
                </Plugins>
                <Listeners>
                    <BeforeDrop Fn="beforerecorddrop" />
                </Listeners>
            </ext:TreeView>
        </View>
    
        <Root>
            <ext:Node Text="My Files" Icon="Folder" Expanded="true" NodeID="check" EmptyChildren="true" />
        </Root>
        <Listeners>
            <NodeDragOver Fn="nodeDragOver" />
        </Listeners>
    </ext:TreePanel>
    And that's it!.. Notice in this case it will pull the Description field on your Web.sitemap file into that second column's contents.

    More elaborate solution
    Now suppose you really really want it to pull the information from server in real time (for example, if there are a lot of information more to get from server and it would just be too cumbersome to hide it on the source tree panel).

    One way to do that would be changing your beforerecorddrop function. I will not dig too deep on this approach unless you really need it and these brief instructions do not help you at all.

    That said, you have just to make beforerecorddrop call a direct method with a callback function. The beforerecorddrop function body would be changed down to:
    1. call the direct method
    2. return false

    The function's body will essentially be copy-pasted to the callback function. In other words, as you drop the node, the direct method passing the node's id will be called with a set up "success" callback that then will be essentially the former beforerecorddrop code block, and then the function will return doing nothing more -- and not finalizing the drop process. That will be done when the direct method returns successfully with the milestone data.

    The direct method use cases (passing paramenter, calling callback and returning a value) are showcased here: DirectMethod overview.

    In-betweens that you may want to:
    - Also use a "failure" callback to display a message to the user should the process fail or exceed a time out (network issues happens!)
    - Ensure the window is properly masked when it is working in background -- you probably have this covered by your line 66!
    - You may also want the mask to be applied only after a given number of seconds -- a quick operation won't require a mask at all. See Duration Messages Example for Ext.NET 3 for examples. They probably work on Ext.NET 2 too.

    Well, and that would pretty much be it. I hope it helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Hi fabricio.murta,,

    Thanks for the reply.

    Actually we had the approach of having all the values saved in the source panel. But as you u have mentioned the data will be too huge.
    And in the image I have shown only one extra column with the folders. But we have almost 40 other columns whose data shud be fetched from the server.

    That's why we are trying for this approach.

    I even tried pulling the data from the server using an ajax call.

       $.ajax({
                    type: "POST",
                    url: "WebForm1.aspx/GetTheData",
                    data: '{name: "Arjun" }',
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                     success: OnSuccess,
                    failure: function(response) {
                        alert(response.d);
                    }
                });
    I will be calling the above ajax call from the beforerecorddrop function. As mentioned in the 'url', I will be hitting the corresponding aspx page and its method 'GetTheData'. But in the 'OnSuccess' method the variable 'data' from "var beforenodedrop = function (node, data, overModel, dropPosition, dropFn) {" was undefined.

            function OnSuccess(response) {
            
                if (Ext.isArray(data.records)) {
                    var records = data.records,
                        rec;
    
                    data.records = [];
    
                    for (var i = 0; i < records.length; i++) {
                        rec = records[i];
    
                        data.records.push({
                            task: rec.get("task"),
                            leaf: true,
                            milestoneCat1: "A",
                            milestoneCat2: "B"
                        });
    
                    }
    
                    return true;
                }
    
            }

    Then I declared some global variables as below:

    var a_node,b_data,c_overModel,d_DropPos,e_drpFn
            var beforenodedrop = function (node, data, overModel, dropPosition, dropFn) {
                debugger;
                a_node = node;
                b_data = data;
                c_overModel = overModel;
                d_DropPos = dropPosition;
                e_drpFn = dropFn;
    
                $.ajax({
                    type: "POST",
                    url: "WebForm1.aspx/GetTheData",
                    data: '{name: "Arjun" }',
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    // success: OnSuccess,
                    failure: function(response) {
                        alert(response.d);
                    }
                });
    
            };

    And tried using the globa variable to push the data. It didn't throw any error but the values dint get bound the to the tree.

     function OnSuccess(response) {
                if (Ext.isArray(b_data.records)) {
                    var records = b_data.records,
                        rec;
    
                    b_data.records = [];
    
                    for (var i = 0; i < records.length; i++) {
                        rec = records[i];
    
                        b_data.records.push({
                            task: rec.get("task"),
                            leaf: true,
                            milestoneCat1: "A",
                            milestoneCat2: "B"
                        });
                    }
    
                    return true;
                }
    
            }
    Can you please check where am I going wrong with this approach.
    Since I have done enough changes in the server side code, providing you with a runnable test case is little difficult.
    Meanwhile I will be trying to use the Direct Method approach to which you have mentioned

    Regards,
    Arjun
  4. #4
    Hi Hi fabricio.murta,


    Can you please Elaborate the below statement with an example:

    "That said, you have just to make beforerecorddrop call a direct method with a callback function. The beforerecorddrop function body would be changed down to:
    1. call the direct method
    2. return false"

    Thanks,
    Arjun
  5. #5
    Hello, here's the full page using the direct method approach to get data for the added row.

    <%@ Page Language="C#" %>
    
    <%@ Import Namespace="System.Collections.Generic" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                SiteMapNode siteNode = SiteMap.RootNode;
                Node node = this.CreateNodeWithOutChildren(siteNode);
                node.AllowDrag = true;
                node.Expanded = true;
                TreePanel1.Root.Add(node);
            }
        }
    
        //page tree node loader handler
        protected void LoadPages(object sender, NodeLoadEventArgs e)
        {
            if (!string.IsNullOrEmpty(e.NodeID))
            {
                SiteMapNode siteMapNode = SiteMap.Provider.FindSiteMapNodeFromKey(e.NodeID);
    
                if (siteMapNode == null)
                {
                    return;
                }
    
                SiteMapNodeCollection children = siteMapNode.ChildNodes;
    
                if (children != null && children.Count > 0)
                {
                    foreach (SiteMapNode mapNode in siteMapNode.ChildNodes)
                    {
                        e.Nodes.Add(this.CreateNodeWithOutChildren(mapNode));
                    }
                }
            }
        }
    
        //dynamic node creation
        private Node CreateNodeWithOutChildren(SiteMapNode siteMapNode)
        {
            Node treeNode;
    
            if (siteMapNode.ChildNodes != null && siteMapNode.ChildNodes.Count > 0)
            {
                treeNode = new Node();
            }
            else
            {
                treeNode = new Ext.Net.Node();
                treeNode.Leaf = true;
            }
    
            treeNode.NodeID = siteMapNode.Key;
            treeNode.Text = siteMapNode.Title;
            treeNode.Qtip = siteMapNode.Description;
    
            return treeNode;
        }
    
        [DirectMethod(ShowMask = true)]
        public string GetMilestone(string categoryId)
        {
            //select milestone from myDatabase.categories where category='" + categoryId + "';"
            var milestone = categoryId + "'s milestone";
    
            return milestone;
        }
    
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head id="Head1" runat="server">
        <title>Drag and Drop betweens two TreePanels - Ext.NET Examples</title>
        <link href="/resources/css/examples.css" rel="stylesheet" />
        <style>
            .tree {
                float: left;
                margin: 20px;
                border: 1px solid #c3daf9;
            }
        </style>
     <ext:XScript ID="XScriptdd1" runat="server">
        <script type="text/javascript">
            var global_recordDropData;
            var beforerecorddrop = function (node, data, overModel, dropPosition, dropFn) {
                global_recordDropData = {
                    node: node,
                    data: data,
                    overModel: overModel,
                    dropPosition: dropPosition,
                    dropFn: dropFn
                };
                
                var me = this;
    
                App.direct.GetMilestone(data.records[0].data.id, {
                    scope: this,
                    success: function(record) {
                        var draggedRecord = global_recordDropData.data.records[0].data
                        var draggedNode = App.TreePanel1.store.getNodeById(draggedRecord.id);
                        var srcTreeRootNode = App.TreePanel1.getRootNode();
    
                        // Fill an array with the path (from leaf to root)
                        var folderHierarchy = [];
                        var parentNode = draggedNode.parentNode;
                        while (parentNode != null && parentNode.id != srcTreeRootNode.id) {
                            folderHierarchy[folderHierarchy.length] = parentNode;
                            parentNode = parentNode.parentNode;
                        }
                
                        var curDestNode = global_recordDropData.overModel;
                        if (curDestNode.isLeaf()) {
                            // Dropped on a leaf that is also root?
                            if (curDestNode.isRoot()) {
                                return false;
                            }
    
                            // Move one level upper, to an actual folder node.
                            curDestNode = curDestNode.parentNode;
                        }
                
                        // Walk from shallowest to deepest path nodes, creating them as necessary
                        for (var i=folderHierarchy.length - 1; i >= 0; i--) {
                            var thisNode = folderHierarchy[i];
                    
                            // Check if the folder already exists
                            var parentExists = false;
                            for (var j in curDestNode.childNodes) {
                                if (curDestNode.childNodes[j].data.text == thisNode.data.text) {
                                    parentExists = true;
                                    break;
                                }
                            }
    
                            // If not, then make a copy of the node into the destination tree
                            if (!parentExists) {
                                curDestNode.appendChild(thisNode.copy());
                            }
    
                            // Get child node on dest tree
                            for (var j in curDestNode.childNodes) {
                                if (curDestNode.childNodes[j].data.text == thisNode.data.text) {
                                    curDestNode = curDestNode.childNodes[j];
                                    break;
                                }
                            }
                        }
    
                        // bind the value fetched from server into the node.
                        var dropNode = draggedNode.copy();
                        dropNode.data.milestone = record;
    
                        // Drop a copy of the node in the deepest level of the structure created
                        curDestNode.appendChild(dropNode);
                    }
                });
    
                // Do not continue normal node drop operation.
                return false;
            };
    
            var nodeDragOver = function (targetNode, position, dragData) {
                //debugger;
                
                var rec = dragData.records[0],
                    isFirst = targetNode.isFirst(),
                    canDropFirst = rec.get('canDropOnFirst'),
                    canDropSecond = rec.get('canDropOnSecond');
                // alert(rec.parentNode.data.text);
                #{HdnFolderName}.setValue(rec.parentNode.data.text);
                return true;//isFirst ? canDropFirst : canDropSecond;
            };
        </script>
        </ext:XScript>
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:Hidden ID="HdnFolderName" runat="server" />
            <ext:ResourceManager ID="ResourceManager1" runat="server"/>
    
            <h1>Drag and Drop betweens two TreePanels</h1>
    
            <p>The TreePanels have a TreeSorter applied in "folderSort" mode.</p>
    
            <p>Both TreePanels are in "appendOnly" drop mode since they are sorted.</p>
    
            <p>Drag along the edge of the tree to trigger auto scrolling while performing a drag and drop.</p>
    
            <p>The data for this tree is asynchronously loaded with a TreeStore.</p>
    
            <div class="tree">
                <ext:TreePanel
                    ID="TreePanel1"
                    runat="server"
                    Border="false"
                    Height="300"
                    Width="250"
                    UseArrows="true"
                    Animate="true">
                    <Store>
                        <ext:TreeStore ID="TreeStore1"
                            runat="server"
                            OnReadData="LoadPages"
                            FolderSort="true">
                            <Proxy>
                                <ext:PageProxy />
                            </Proxy>
                            <Sorters>
                                <ext:DataSorter Property="text" />
                            </Sorters>
                        </ext:TreeStore>
                    </Store>
                    <View>
                        <ext:TreeView ID="TreeView1" runat="server">
                            <Plugins>
                                <ext:TreeViewDragDrop ID="TreeViewDragDrop1" runat="server" AppendOnly="true" />
                            </Plugins>                      
                        </ext:TreeView>
    
                    </View>
    
                </ext:TreePanel>
            </div>
    
            <div class="tree">
            <ext:TreePanel
                ID="TreePanel2"
                runat="server"
                Height="300"
                Width="250"
                Border="false"
                UseArrows="true"
                AutoScroll="true">
                <Fields>
                    <ext:ModelField Name="text" />
                    <ext:ModelField Name="milestone" />
                </Fields>
                <ColumnModel>
                    <Columns>
                        <ext:TreeColumn runat="server" Text="Folders / Programs" DataIndex="text" Flex="1" />
                        <ext:Column runat="server" Text="Milestone Cat1" DataIndex="milestone" />
                    </Columns>
                </ColumnModel>
                <View>
                    <ext:TreeView ID="TreeView2" runat="server">
                        <Plugins>
                            <ext:TreeViewDragDrop ID="TreeViewDragDrop2" runat="server" AppendOnly="true"   />
                        </Plugins>
                        <Listeners>
                            <BeforeDrop Fn="beforerecorddrop" />
                        </Listeners>
                    </ext:TreeView>
                </View>
    
                <Root>
                    <ext:Node Text="My Files" Icon="Folder" Expanded="true" NodeID="check" EmptyChildren="true" />
                </Root>
                <Listeners>
                    <NodeDragOver Fn="nodeDragOver" />
                </Listeners>
            </ext:TreePanel>
            </div>
        </form>
    </body>
    </html>
    Notice how most of the beforerecorddrop body became part of the direct method's callback to build the node structure only when it can actually be dropped and data was fetched.

    A new field is added to the record, called milestone, that is used on the tree grid.

    It seems there's an issue with scoping, so I ended up also using the global variable approach. Although it is said to be fixed on thread Direct Method scope option not working?, I couldn't have your example working for it. I might open an issue to investigate this.

    I hope this helps!

    EDIT: Ops, my bad! We're on Ext.NET 2.x, where scoping on direct method functions were not supported. The global variable seems not to be the best way, yet one alternative for Ext.NET 2.
    Last edited by fabricio.murta; Feb 24, 2016 at 4:57 PM.
    Fabrício Murta
    Developer & Support Expert
  6. #6
    Thanks fabricio.murta,

    Its working fine. :)
  7. #7
    Glad to be of help! Thanks for letting us know the solution is good for you!
    Fabrício Murta
    Developer & Support Expert
  8. #8
    Hi fabricio.murta,

    The code you have given works fine when I drag a child and drop it on the folder. But when I drag an entire folder and drop it, its not working as expected.
    Actually I had asked the same question in a different thread, wherein I had all the data saved in the source tree panel, and when I drag and drop a folder I was asked to check if the dragged item is a parent or a leaf. If its folder need not do any logic just returning true, else go inside the loop and execute the code you have shared. Then I had tried something like this:

      if(global_recordDropData.data.records[0].isLeaf())
                    { //execute the code
    } 
    else
    {
    return true;
    }
    And this had worked.

    But now I will be fetching the data from the server on drop of a node. I tried using the same approach I was asked to do but its not working as expected.
    Please help.
  9. #9
    Hello @ArjunVasisht!

    You probably have to discern folders from leaves in the code behind and bring this information when you perform the server-side code. Then when you create it as a record set is as a leaf or folder accordingly. Then I believe the original concept would do. Well, that is, if I could correctly understand your problem.
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. [CLOSED] custom tree drag & drop
    By susanz in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Oct 29, 2014, 5:05 PM
  2. [CLOSED] Get destination treenode in Grid to Tree drag drop
    By jchau in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: May 08, 2013, 12:54 AM
  3. [CLOSED] drag and drop in tree panels question
    By bogc in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Aug 31, 2011, 7:43 PM
  4. Replies: 13
    Last Post: Jul 14, 2011, 1:45 PM
  5. Replies: 0
    Last Post: Aug 10, 2010, 5:27 AM

Tags for this Thread

Posting Permissions