jquery-treetable icon indicating copy to clipboard operation
jquery-treetable copied to clipboard

Add option to append nodes at top. [PR request pending]

Open Nejaa opened this issue 8 years ago • 0 comments

EDIT : See PR request

I had this need lately. I made it work by adding a non core parameter to the options :

_table.treetable({
    expandable: true,
    clickableNodeNames: true,
    onNodeExpand: onNodeExpand,
    prependRootNodes: true //Not a core parameter.
});

Then I modified the loadBranch function like that :

loadBranch: function (node, rows) {
            //...          
            if (node == null) { // Inserting new root nodes
                if (settings.prependRootNodes)
                    this.prepend(rows);
                else
                    this.append(rows);
            } else {
                var lastNode = this.data("treetable").findLastNode(node);
                rows.insertAfter(lastNode.row);
            }
            //...
        }

Of course this isn't the only way to go at it. My first idea was to add a parameter to loadBranch that would tell the function to append at the top only for this load request.

In any cases both options wouyld be nice to have in the core plugin. I hope this is helpfull :)

Nejaa avatar Nov 16 '17 21:11 Nejaa