Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 912653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:25:11+00:00 2026-05-15T17:25:11+00:00

I had populated data in TreeView control. How will I drag a particular child

  • 0

I had populated data in TreeView control. How will I drag a particular child node from a parent node and drop the dragged one to a DIV or any portion, using JQUERY ? I know in jquery, there are methods “draggable” and “droppable” to make this possible. But I want to drag a particular child node and drop it.

Or atleast How to fetch the text/id of a particular child node using jquery ? I hope I can drag,if I can fetch the child node

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T17:25:12+00:00Added an answer on May 15, 2026 at 5:25 pm

    Ok I add this as another answer because the comment box is to small,

    To hide/show an item while dragging you can use the start and stop events.

    This example shows/hides the +/- (collapse/uncollapse) icon next to the treenode text while dragging but you can easily modify it to hide/show the checkboxes if present.

    <script type="text/javascript">
    $(function () {
        $(".treeNode").draggable({
                start: function (event, ui) {
    
                    var previousTd = $(this).parent().prev() ;
                    $("img", previousTd).css("visibility", "hidden");
                },
                stop: function (event, ui) {
                    var previousTd = $(this).parent().prev();
                    $("img", previousTd).css("visibility", "visible");
                });
        $("#<%= TreeView1.ClientID%>").droppable({
            drop: function (event, ui) {
                alert(ui.draggable.text());
            }
        });
    });
    

    I’ll try to have a look at the clone problem.

    — edit —

    Apparently the clone problem is only in IE and is caused by the

     <NodeStyle CssClass="treeNode" />
    

    In conjunction with

    $(".treeNode").draggable(...
    

    This puts the treeNode class not only on the “a” tag but also on the surrounding “td” tag. So by using the .treeNode selector the draggable method is executed twice … This is not the case in FF.

    You could solve this by just changing the selector in “#<%= TreeView1.ClientID%> a.treeNode”
    So with the afore mentioned aspx you would get the following script.

        $(function () {
            $("#<%= TreeView1.ClientID%> a.treeNode").draggable({
                appendTo: 'body',
                helper: 'clone',
                start: function (event, ui) {
    
                    var previousTd = $(this).parent().prev();
                    $("img", previousTd).css("visibility", "hidden");
                },
                stop: function (event, ui) {
                    var previousTd = $(this).parent().prev();
                    $("img", previousTd).css("visibility", "visible");
                },
                zIndex: '100'
            });
    
            $("#<%= TreeView1.ClientID%>").droppable({
                drop: function (event, ui) {
                    alert(ui.draggable.text());
                }
            });
        });
    </script>
    

    — edit —

    In answer to your comment:

    To get the value of the dragged node you can use javascript string manipulation to filter it out of the href attribute (treenode renders the value in the href attr).

    Your javascript in the drop function could look like the following. (still need to do some checking for null values ofcourse)

    var hrefParts = $(ui.draggable.context.href.split("\\"));
    var nodeValue = hrefParts[hrefParts.length - 1];
    nodeValue = nodeValue.substring(0, nodeValue.length - 2);
    alert(nodeValue);                    
    

    Or you can make it a little cleaner client-side by inheriting Treenode and wrap every Treenode by a div with a custom attribut in which you put your clientside id.

    Your custom treenode could look like this

    public class WrappedTreeNode : TreeNode
    {
        public string ClientValue { get; set; }
    
        protected override void RenderPreText(HtmlTextWriter writer)
        {
            writer.WriteBeginTag("div");
            //you can simply use the base.Value aswell here if you want them to be the same
            writer.WriteAttribute("id", ClientValue);
            base.RenderPreText(writer);
        }
    
        protected override void RenderPostText(HtmlTextWriter writer)
        {
            base.RenderPostText(writer);
            writer.WriteEndTag("div");
        }        
    }
    

    Then in your aspx use (register you custom web control assembly first)

    <ServerControls:WrappedTreeNode Text="Bradley" ClientValue="ID-1221"/>
    

    instead of

    <asp:TreeNode Text="Bradley" Value="ID-1221"/>
    

    And your javascript stays nice and clean

    alert($(ui.draggable).parent().attr("id"));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i've populated a dropdownlist control with different text properties but each text properties had
I've developed an application that populates a treeview from hierachical data in a database.
I am new to VS 2010 and MVC2.Here i had populated a dropdownlist from
I had to delete all the rows from a log table that contained about
I have built an iPhone app that needs to pull data from a server.
I've got a page which will have about ten drop down lists which are
This is the desired result Ineeded. I had populated State(RowGroup), Male(ColGroup), Year(ColGroup) and the
I have a UITableView that's populated using core data & sqlite. I'd like to
I had a comboBox and loading the datadynamically from the server. i need to
Had an interesting discussion with some colleagues about the best scheduling strategies for realtime

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.