Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add and expand all / collapse all to a jQuery TreeTable in an Apache Wicket application?

I am using the jQuery plugin TreeTable in a similar manner mentioned in blog entry A jQuery tree table for Wicket .

What I want to do now is attaching some JavaScript code in an expand all / collapse all button(s).

The following code doesn't seem to work.

$(".treeTable").treeTable().expand();

And also

$(".treeTable").treeTable();
$(".treeTable").expand();
like image 224
shmoo Avatar asked Dec 28 '22 21:12

shmoo


1 Answers

Very nice challenge.

I've built an 'expand all' feature (because it doesn't have it). Here you have it:

$.fn.expandAll = function() {
    $(this).find("tr").removeClass("collapsed").addClass("expanded").each(function(){
        $(this).expand();
    });
};

To use it, just do:

$(".treeTable").expandAll();

I hope this helps.

like image 65
Edgar Villegas Alvarado Avatar answered Jan 21 '23 17:01

Edgar Villegas Alvarado