jquery treeTable sorting using sortBranch

1.3k views Asked by At

I am not very expert on jquery, I am using the jquery treeTable from Ludo and it is really nice.

But I am not able to sort the folder-node's childrens using the "sortBranch" as suggested in the documentation.

In particular I get the error:

TypeError: node is undefined node.children.sort(sortFun);

It seems I am not passing the proper node object, see below my code:

$("#trackfileslist .folder").each(function(index,key) {

    $("#trackfileslist").treetable("sortBranch", $(this));

});

I was not able to find some sample so far.

Anyone's help is very much appreciated.

Thanks.

1

There are 1 answers

0
Raj Wilson Dsouza On

This should work

<script>
var node = '';
$("#trackfileslist .folder").each(function(index,key) {
   node = $("#trackfileslist").treetable("node", $(this).attr('data-tt-id'));
   $("#trackfileslist").treetable("sortBranch", node);
});
</script>