Search code examples
jqueryjquery-pluginstreetable

jQuery treeTable saving state on page refresh


I am using the jquery treetable plugin for showing my data as a tree view in a table. I dint find a detailed documentation about this plugin on the net. What i need is if the user expands sum nodes and then he reopens or refreshes the page the node expansion shud be in its previous state (i.e the nodes that were expanded shud remain expanded instead of collapsing into their parent nodes). at this stage i hav the node names to expand, stored in the cookie but i dont know how to mess with this jQuery plugin since i dont have a gud grasp of jQuery syntax. there is a function in this plugin as

// Reveal a node by expanding all ancestors
  $.fn.reveal = function() {
    $(ancestorsOf($(this)).reverse()).each(function() {
      initialize($(this));
      $(this).expand().show();
    });

    return this;
  };

which i think might be useful for achieving my goal...but i hav no idea hw to use this, or alter this or call it from :S


Solution

  • got it...just call $(nodeElement).reveal() from the javascript on all the elements stored in the cookie('nodeElement' comes from the cookie) and on next refresh everything will be in its previous state