Jump to content

Recommended Posts

Hi,

 

I populate a tree view from database using jquery and ajax.

the next phase I want is to expand a scpecific parentId.

Here is my code:

<div class="col md-2" id="treeview_json">
                
</div>
$(document).ready(function()
{
	var pageURL = $(location).attr("href");
    var url = '/path/to/fill_sidebar.php';
    $.ajax
    ({
    	type: "GET",  
        url: url,
        dataType: "json",   
        success: function(data)  
        {
	        var parent_node_id;
            var onTreeNodeSelected = function (e, node) 
            {
	            GetNodeData(node.link, node.tags)
            }
            $('#treeview_json').treeview
            ({
 	         	data: data,
                backColor: 'white',
                expandIcon: 'fa fa-plus fa-fw',
                collapseIcon: 'fa fa-minus fa-fw',
                showBorder: false,
                enableLinks: true,
                onNodeSelected: onTreeNodeSelected,
            });
       },
       error: function(response)  
       {
       		alert(response.errorMsg);
       } 
   });
});

I want to get a specific parentId of a node and after filling the treeview, i want to expand it

something like 

$('#treeview_json').treeview('expandNode', [node.parentId]);

Can anyone explain to me how can I do that?

 

Thank you

2 hours ago, ohad said:

Can anyone explain to me how can I do that?

You need to read the documentation for whatever tree view library you are using and figure it out.  There is no standard tree view widget so there's no standard way to do what you want.

If you can't figure it out from the documentation, then at the very least you need to specify which library you are using to get help with it.

 

7 hours ago, ohad said:

something like 

$('#treeview_json').treeview('expandNode', [node.parentId]);

Can anyone explain to me how can I do that?

It's weird you mention that because the very same documentation you couldn't find says that's exactly what you're supposed to do.
Could it be that your question isn't so much "how" but rather "why does this method call not work"?

Where are you putting that code? Where did "node" get defined? Any errors in the browser's console?

I saw in the documentary how to expand a node.

My problem is that I don't know which event should trigger the expanding.

I need an event like onNodeSelected that call a function that do that expansion. The node will be defined under that function

I hope i explained myself better

Thank you

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.