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

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

Expand Messages
  • Satyam
    Nov 4, 2008
    • 0 Attachment
      Congratulations, you have found a bug!

      Fortunately it is easy to patch, simply add this code to your page
      somewhere after the YUI library is loaded and before you create the
      first TreeView instance:

      (function () {
      var oldGetNodeDefinition = YAHOO.widget.Node.prototype.getNodeDefinition;
      YAHOO.widget.Node.prototype.getNodeDefinition = function () {
      var def = oldGetNodeDefinition.call(this);
      if (!this.expanded) {delete def.expanded;}
      return def;
      };
      })();


      Do you mind filing a bug report in SourceForge? That's the way to ensure
      the YUI team keeps track of it and you will be notified whenever it gets
      fixed.

      http://developer.yahoo.com/yui/articles/reportingbugs/


      Satyam


      Lee.M wrote:
      >>
      >> but you also have expandComplete, fired afterwards.
      >>
      >
      > I didn't see expandComplete/collapseComplete
      > at http://developer.yahoo.com/yui/treeview/ thanks!
      >>
      >> > When the data struct has 'expanded = true' it is indeed re-rendered
      >> > from the cookie as expanded. The problem is collapses are not
      >> > remembered...
      >> >
      >> > Does it need an explicit 'expanded = false' ? if so, what do i do to
      >> > make that happen?
      >> >
      >> >
      >> 'expanded = false' and no 'expanded' at all is the same, after all, no
      >> 'expanded' means 'expanded = undefined' which equates to false anyway.
      >> The method to extract each node definition tries to avoid being too
      >> verbose by omitting defaults or implicit values.
      >>
      > That's the problem, rebuilding said tree seems to ignore expanded =fals
      >
      > I can get it to save the stringified tree into a cookie on expand and
      > collapse.
      >
      > the only values ever re-applied via the cookie are ones that were
      > expanded.
      >
      > *step 1) visit page w/ 2 nodes - both collapsed (IE default) - without
      > the cookie*
      > [no alert]
      >
      > *step 2) expand node 1*
      > alert: expandComplete
      > [{"children":[{"children":[{"label":"item
      > 0-0-0","type":"TextNode"},{"label":"item
      > 0-0-1","type":"TextNode"}],"label":"List
      > 0-0","type":"TextNode"}],"expanded":true,"label":"List
      > 0","type":"TextNode"},{"children":[{"children":[{"label":"item
      > 0-1-0","type":"TextNode"},{"label":"item
      > 0-1-1","type":"TextNode"}],"href":"HTTP://developer.yahoo.com/yui
      > <HTTP://develo%0Aper.yahoo.com/yui>","label":"YUI","target":"_new","title":"go
      > to YUI Home Page","type":"TextNode"}],"label":"item
      > 0-1","type":"TextNode"}]
      >
      > *step 3) revisit page, node 1 is expanded! ye haw!*
      > alert: Reinstantiate from cookie
      > [{"children":[{"children":[{"label":"item
      > 0-0-0","type":"TextNode"},{"label":"item
      > 0-0-1","type":"TextNode"}],"label":"List
      > 0-0","type":"TextNode"}],"expanded":true,"label":"List
      > 0","type":"TextNode"},{"children":[{"children":[{"label":"item
      > 0-1-0","type":"TextNode"},{"label":"item
      > 0-1-1","type":"TextNode"}],"href":"HTTP://developer.yahoo.com/yui","label":"YUI","target":"_new","title":"go
      > to YUI Home Page","type":"TextNode"}],"label":"item
      > 0-1","type":"TextNode"}]
      >
      > *step 4) collapse node 1*
      > alert: collapseComplete
      > [{"children":[{"children":[{"label":"item
      > 0-0-0","type":"TextNode"},{"label":"item
      > 0-0-1","type":"TextNode"}],"label":"List
      > 0-0","type":"TextNode"}],"expanded":true,"label":"List
      > 0","type":"TextNode"},{"children":[{"children":[{"label":"item
      > 0-1-0","type":"TextNode"},{"label":"item
      > 0-1-1","type":"TextNode"}],"href":"HTTP://developer.yahoo.com/yui","label":"YUI","target":"_new","title":"go
      > to YUI Home Page","type":"TextNode"}],"label":"item
      > 0-1","type":"TextNode"}]
      >
      > *step 5) revisit page, node 1 is expanded still*
      > alert: Reinstantiate from cookie
      > [{"children":[{"children":[{"label":"item
      > 0-0-0","type":"TextNode"},{"label":"item
      > 0-0-1","type":"TextNode"}],"label":"List
      > 0-0","type":"TextNode"}],"expanded":true,"label":"List
      > 0","type":"TextNode"},{"children":[{"children":[{"label":"item
      > 0-1-0","type":"TextNode"},{"label":"item
      > 0-1-1","type":"TextNode"}],"href":"HTTP://developer.yahoo.com/yui","label":"YUI","target":"_new","title":"go
      > to YUI Ho me Page","type":"TextNode"}],"label":"item
      > 0-1","type":"TextNode"}]
      >
      > ------------------------------------------------------------------------
      >
      >
      > No virus found in this incoming message.
      > Checked by AVG - http://www.avg.com
      > Version: 8.0.175 / Virus Database: 270.8.5/1764 - Release Date: 03/11/2008 7:46
      >
      >
    • Show all 21 messages in this topic