Loading ...
Sorry, an error occurred while loading the content.

40255Re: [ydn-javascript] Is it possible to setup TreeView to keep it's state?

Expand Messages
  • Satyam
    Nov 2, 2008
    • 0 Attachment
      Cookies have to be strings or things that have string representations.
      The string representation of an object is "[object]"which is not very
      useful.

      You have to use the JSON utility to convert the tree definition to a
      string and store that string into the cookie. On the way back, you read
      the cookie, parse it with the JSON utility and use that as the second
      argument to the TreeView constructor.

      Satyam


      Lee.M wrote:
      > On Nov 1, 2008, at 12:12 PM, Satyam wrote:
      >
      >
      >> See:
      >>
      >> http://developer.yahoo.com/yui/examples/treeview/tv-markup.html
      >>
      >> The second tree is made from the definition of the first and the third
      >> made of the definition of a branch. The example does not show saving
      >> it
      >> into a cookie, but that's just an intermediate storage step which
      >> can be
      >> done anyway you want.
      >>
      >>
      >
      > thanks, the thing I can't quite get is how to store it in a cookie in
      > such a way so as to reuse it later:
      >
      > Saving it like this:
      > YAHOO.util.Cookie.set("name", tree.getTreeDefinition());
      > or
      > YAHOO.util.Cookie.set("name", tree);
      >
      > var cookie = YAHOO.util.Cookie.get("name");
      >
      > Doesn't seem to let you re use it like this:
      > tree = new YAHOO.widget.TreeView("id", cookie. getTreeDefinition());
      > or
      > tree = new YAHOO.widget.TreeView("id", cookie);
      >
      > tree.render();
      >
      >> Satyam
      >>
      >> Lee.M wrote:
      >>
      >>>> On Jul 7, 2008, at 2:51 PM, Eric Miraglia wrote:
      >>>>
      >>>>
      >>>>
      >>>>> Lee.M,
      >>>>>
      >>>>>
      >>>>> This is a reasonable feature request and it's something that we
      >>>>> hope to add to the 2.6.0 edition of TreeView.
      >>>>>
      >>>>>
      >>> Now that 2.6.0 is out I'm trying to see if this funtionality is
      >>> available.
      >>>
      >>> I'm assuming I'd use getTreeDefinition() to get the "serializable"
      >>> tree definition.
      >>>
      >>> I'd like to have the "default" tree in the <div id="markup">.
      >>>
      >>> if we have a 'tree structure' cookie:
      >>> render it that way
      >>>
      >>> if we don't render the div as is
      >>>
      >>> Any changes would need to be re-saved in the cookie.
      >>>
      >>> Has anyone successfully done this? Any examples?
      >>>
      >>> thanks!
      >>>
      >>> --
      >>> Lee.M
      >>>
      >>>
      >>>
      >>>>> For now, I would simply advise writing a function that crawls your
      >>>>> tree and serializes its state and another function that can read
      >>>>> that state as it builds the tree to expand/collapse nodes as
      >>>>>
      >> needed.
      >>
      >>>>> Regards,
      >>>>> Eric
      >>>>>
      >>>>>
      >>>>> On Jul 2, 2008, at 5:21 PM, Lee.M wrote:
      >>>>>
      >>>>>
      >>>>>
      >>>>>> Howdy YUI folks!
      >>>>>>
      >>>>>> I can't seem to find any info on having a stateful treeview.
      >>>>>>
      >>>>>> For example, make a simple treeview menu that has a form that
      >>>>>> submits
      >>>>>> to itself and hit submit (or just hit refresh).
      >>>>>>
      >>>>>> The tree resets to its initial state.
      >>>>>>
      >>>>>> I realize I could pass GET or POST params with nodes I want to be
      >>>>>> open
      >>>>>> and closed and generate the JS dynamically each request *but*
      >>>>>>
      >> it'd
      >>
      >>>>>> be
      >>>>>> really cool if, when its first drawn it draws it from a cookie if
      >>>>>> its
      >>>>>> got it or the hard coded values if not, creates a new cookie if
      >>>>>> needed, and on node open and close it updates the cookie
      >>>>>>
      >>>>>> is there any mechanism to get this stateful treeview behavior?
      >>>>>>
      >>>>>> TIA, Lee.M
      >>>>>>
      >>>>>>
      >>>>>>
      >>> ------------------------------------
      >>>
      >>> Yahoo! Groups Links
      >>>
      >>>
      >>>
      >>> ----------------------------------------------------------
      >>>
      >>>
      >>> No virus found in this incoming message.
      >>> Checked by AVG - http://www.avg.com
      >>> Version: 8.0.175 / Virus Database: 270.8.5/1759 - Release Date:
      >>>
      >> 31/10/2008 16:10
      >>
      >>>
      >>
      >
      >
      > ------------------------------------
      >
      > Yahoo! Groups Links
      >
      >
      >
      > ------------------------------------------------------------------------
      >
      >
      > No virus found in this incoming message.
      > Checked by AVG - http://www.avg.com
      > Version: 8.0.175 / Virus Database: 270.8.5/1760 - Release Date: 01/11/2008 9:36
      >
      >
    • Show all 21 messages in this topic