BinkWu / jquery-checktree

Automatically exported from code.google.com/p/jquery-checktree
0 stars 0 forks source link

Allow for expanded sub-lists on startup #5

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
When a checktree is instantiated all sub-lists are collapsed by default,
and that fact is noted in the code comments (v1.2 line 127).

You should be able to specify that certain nodes begin in the expanded
state.  The script should check for a class of 'open' on the ul element in
question.

I made the following changes to my copy, and tested that a node can start
expanded or collapsed.  The default is collapsed if the 'open' class is
missing from the ul element.  I initially was going to look for 'expanded'
on the ul, but that resulted in the expanded icon to repeat over the entire
child list due to the css style.  Additionally, 'open' is used in other
treeview widgets to indicate nodes that should be open at initialization.

On line 37, add this
    $tree.find("li ul:not(.open)").hide();
On line 40, remove this
    .hide()

Update line 127 to add correct arrow based on visibility of the ul:
   if (jQuery(this).is(":has(ul:hidden)"))
      $arrow.addClass("collapsed"); // Should start collapsed
   else
      $arrow.addClass("expanded"); // Should start expanded

Please feel free to include this change in your master copy for everyone.

- Michael Lang

Original issue reported on code.google.com by xquis...@gmail.com on 18 Oct 2008 at 3:48

GoogleCodeExporter commented 8 years ago
This definitely would be useful, I will test out your patch and apply it as 
soon as I
can. Rather than "open" I will call this class "expanded" to make sure there is 
no
confusion.

Original comment by jgeewax on 9 Nov 2008 at 12:19

GoogleCodeExporter commented 8 years ago
Hello, I was wondering if this patch has been tested? I would also like to 
specify
the nodes that are expanded onload. I have just tried to apply patch 
instructions but
I'm not quite following correctly, getting a JS error.

Many thanks.

Original comment by losts...@gmail.com on 9 Mar 2009 at 9:43

GoogleCodeExporter commented 8 years ago
Are you using the latest version, 0.22?
http://code.google.com/p/jquery-checktree/source/browse/trunk/jquery.checktree.j
s

My addition was for version 0.20.  Do not apply my patch to version 0.22 as 
those 
capabilities are already supposed to be incorporated into 0.22 but with a 
slightly 
different implementation.

I have not tested 0.22 yet.  I am still using my modified version of 0.20.

Original comment by xquis...@gmail.com on 10 Mar 2009 at 2:28

GoogleCodeExporter commented 8 years ago
If it's incorporated into 0.22 - what class do you give a UL for it to be 
expanded?

Original comment by Mitchell...@gmail.com on 22 Jul 2009 at 6:45

GoogleCodeExporter commented 8 years ago
Hello how can i keep the first checkbox expanded? Thank you.

Original comment by chumma.c...@gmail.com on 27 Sep 2010 at 3:52

GoogleCodeExporter commented 8 years ago
Any progress on this? It doesn't seem to work.

Original comment by scott.ro...@gmail.com on 12 Apr 2011 at 8:57

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
It seems like this project isn't being actively maintained any more, so I've 
forked the codebase on Github and included this functionality.  The code has 
also been updated to support newer versions of jQuery and has been tested 
against jQuery 1.7.0 and 1.9.1. The fork can be found at 
https://github.com/yeurch/CheckTree.

Add the class 'expanded' to a ul in the forked version, and it will start off 
in the expanded state.

Original comment by r.d.fawcett on 24 Apr 2013 at 9:57