maxazan / jquery-treegrid

TreeGrid plugin for jQuery
http://maxazan.github.io/jquery-treegrid
MIT License
553 stars 222 forks source link

How do I implement savestate and a expand/collapse all button? #48

Closed perlfan2009 closed 8 years ago

perlfan2009 commented 8 years ago

Hi there - thanks for this treegrid! As a JS beginner I have a few basic issues with adapting the tree to my needs. Firstly, I like to know how I can trigger $('#tree').treegrid('expandAll'); with a button or a checkbox for example. Can somebody help? Secondly, savestate is not working if applied as shown in the savestate example. initialState works however, but if I insert the savestate : true line, all the node arrows disappear, so there must be some issue here. Thanks for help! Frank

webbird commented 8 years ago

Try (example):

HTML (you can use a button element as well): <a href="#" id="pagetree-expand-all">Expand all</a>

jQuery: $('a#pagetree-expand-all').on('click',function(e) { $('.treetable').treegrid('expandAll'); });

Make sure the ID is unique!

perlfan2009 commented 8 years ago

Thank you for this example, webbird :-) In the meantime maxazan helped me with my problem. "expand all" didn't work on my site as it had some html errors - after removing some redundant span tags it worked.

savestate didn't work even though implemented as shown in the example - after adding the jquery.cookie.js reference it worked right away :-)

Hope this helps also other users. Regards, Frank