Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140734

Expand/Collapse jQuery treetable

$
0
0

I am using the treetable library from jQuery and I am trying to do an accordion type-like behaviour, such that when I open one of the levels and it expands, I want to collapse the other level that was previously opened. I do not know how to implement this behaviour using the jQuery treetable library.

This is the code for my treetable:

function buildTreeTable(tree){

    $("#example").treetable({
        expandable:     true,
        onNodeExpand:   nodeExpand,
        onNodeCollapse: nodeCollapse
    });

function nodeExpand () {
        getNode(this.id); 
 }


function nodeCollapse () {
         console.log("Collapsed: " + this.id);
    }

function getNode(parentNode){
        id = parentNode;
        console.log("The new var is", id);
        console.log("The id of the parent is: ", parentNode);
        var parentNode = $("#example").treetable("node", parentNode);
        $("#example").treetable("unloadBranch", parentNode);
    console.log("parent node",parentNode);
}

Thanks in advance!


Viewing all articles
Browse latest Browse all 140734

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>