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

Re: [ydn-javascript] Re: TreeView - Collapse sync ?

Expand Messages
  • Satyam
    ... Actually, no, that is a function to be called in order to load nodes, not once it is loaded. Anyway, if you didn t use it, that cannot be the problem. ...
    Message 1 of 6 , Aug 31, 2008
    • 0 Attachment
      matthew_be wrote:
      > Thank you for your support!
      >
      > If I understood, you were talking about the function called once the
      > data is loaded:
      > tree.setDynamicLoad(loadNodeData, currentIconMode);
      >
      >
      Actually, no, that is a function to be called in order to load nodes,
      not once it is loaded. Anyway, if you didn't use it, that cannot be the
      problem.
      > Unfortunately I don't know how to pass a variable in this callback
      > function which could allow me to check what needs to be done.
      >

      That is what event listeners are there for. You tell what event you
      want to listen to and provide a function (callback) that will handle
      it. The expandComplete event which I mentioned is one such. If you
      used them jQuery style, then it is just a matter of handling a different
      syntax. In YUI you order the node expanded and you listen for the
      signal that it has been completed, but you do that in two separate calls.

      Satyam

      > I wish there was a callback function triggered when the node is
      > expanded, jQuery-style:
      > node.expand(function() { ... });
      > (jQuery provides callback functions for most of the asynchronous events)
      >
      > Anyway I found a solution to my problem :
      > check dynamicLoadComplete property, once it is set to true,
      > continue code ... couldn't find another solution
      >
      > function clickGemeente(gemeente) {
      > tree = YAHOO.widget.TreeView.getTree("op");
      > var root = tree.getRoot();
      > var gem = root.children[1];
      > if(!gem.expanded) gem.expand();
      > expandGem(gem, gemeente);
      > }
      >
      > function expandGem(gem, gemeente) {
      > if(!gem.dynamicLoadComplete)
      > setTimeout( function(){ expandGem(gem, gemeente) }, 200);
      > else {
      > for (var i=0, j=gem.children.length; i<j; i++) {
      > var node = gem.children[i];
      > if(node.data.label == gemeente) {
      > $.scrollTo( $('#' + node.getElId()) );
      > node.expand();
      > break;
      > }
      > }
      > }
      > }
      >
      >
      >
      >
      > --- In ydn-javascript@yahoogroups.com, Satyam <satyam@...> wrote:
      >
      >> If you ask to load nodes dynamically, dynamic loading will be done
      >> asynchronously, if the nodes were already loaded, there will be no
      >> delay. Nothing the expand method can do much about. If you asked
      >>
      > it to
      >
      >> load dynamically, that will happen asynchronously. If you need to do
      >> things with the nodes once they get loaded, listen to the
      >>
      > expandComplete
      >
      >> event.
      >>
      >> Satyam
      >>
      >>
      >> matthew_be wrote:
      >>
      >>> Hi,
      >>>
      >>> When a user clicks on a link of my webpage,
      >>> I would like to expand automatically a specific leaf in my tree.
      >>>
      >>> How can I achieve this ?
      >>>
      >>> I tried to use the 'expand' function of the nodes where this leaf is
      >>> located, but the problem is that the expand function is asynchronous :
      >>>
      >>> var gem = root.children[1];
      >>> if(!gem.expanded) gem.expand();
      >>> alert(gem.children.length); // displays 0 because the children are
      >>> loaded asynchronously
      >>>
      >>> Thank you for any help ... !
      >>>
      >>>
      >>> ------------------------------------
      >>>
      >>> Yahoo! Groups Links
      >>>
      >>>
      >>>
      >>>
      >>>
      > ------------------------------------------------------------------------
      >
      >>> No virus found in this incoming message.
      >>> Checked by AVG - http://www.avg.com
      >>> Version: 8.0.169 / Virus Database: 270.6.13/1642 - Release Date:
      >>>
      > 29/08/2008 18:12
      >
      >>>
      >
      >
      >
      > ------------------------------------
      >
      > Yahoo! Groups Links
      >
      >
      >
      > ------------------------------------------------------------------------
      >
      >
      > No virus found in this incoming message.
      > Checked by AVG - http://www.avg.com
      > Version: 8.0.169 / Virus Database: 270.6.13/1642 - Release Date: 29/08/2008 18:12
      >
      >
    • matthew_be
      I do not think it is just a matter of syntax: When the user clicks on a specific link in my web app, I want to expand a node in my tree. If I use the
      Message 2 of 6 , Aug 31, 2008
      • 0 Attachment
        I do not think it is just a matter of syntax:

        When the user clicks on a specific link in my web app,
        I want to expand a node in my tree.

        If I use the exandComplete callback function,
        this code will be executed for every expandComplete events.
        In jQuery I can bind a callback function for one specific asynchronous
        call.

        I'll have to stick with the setTimeout function and test the
        dynamicLoadComplete variable.


        --- In ydn-javascript@yahoogroups.com, Satyam <satyam@...> wrote:
        >
        >
        >
        > matthew_be wrote:
        > > Thank you for your support!
        > >
        > > If I understood, you were talking about the function called once the
        > > data is loaded:
        > > tree.setDynamicLoad(loadNodeData, currentIconMode);
        > >
        > >
        > Actually, no, that is a function to be called in order to load nodes,
        > not once it is loaded. Anyway, if you didn't use it, that cannot be
        the
        > problem.
        > > Unfortunately I don't know how to pass a variable in this callback
        > > function which could allow me to check what needs to be done.
        > >
        >
        > That is what event listeners are there for. You tell what event you
        > want to listen to and provide a function (callback) that will handle
        > it. The expandComplete event which I mentioned is one such. If you
        > used them jQuery style, then it is just a matter of handling a
        different
        > syntax. In YUI you order the node expanded and you listen for the
        > signal that it has been completed, but you do that in two separate
        calls.
        >
        > Satyam
        >
        > > I wish there was a callback function triggered when the node is
        > > expanded, jQuery-style:
        > > node.expand(function() { ... });
        > > (jQuery provides callback functions for most of the asynchronous
        events)
        > >
        > > Anyway I found a solution to my problem :
        > > check dynamicLoadComplete property, once it is set to true,
        > > continue code ... couldn't find another solution
        > >
        > > function clickGemeente(gemeente) {
        > > tree = YAHOO.widget.TreeView.getTree("op");
        > > var root = tree.getRoot();
        > > var gem = root.children[1];
        > > if(!gem.expanded) gem.expand();
        > > expandGem(gem, gemeente);
        > > }
        > >
        > > function expandGem(gem, gemeente) {
        > > if(!gem.dynamicLoadComplete)
        > > setTimeout( function(){ expandGem(gem, gemeente) }, 200);
        > > else {
        > > for (var i=0, j=gem.children.length; i<j; i++) {
        > > var node = gem.children[i];
        > > if(node.data.label == gemeente) {
        > > $.scrollTo( $('#' + node.getElId()) );
        > > node.expand();
        > > break;
        > > }
        > > }
        > > }
        > > }
        > >
        > >
        > >
        > >
        > > --- In ydn-javascript@yahoogroups.com, Satyam <satyam@> wrote:
        > >
        > >> If you ask to load nodes dynamically, dynamic loading will be done
        > >> asynchronously, if the nodes were already loaded, there will be no
        > >> delay. Nothing the expand method can do much about. If you asked
        > >>
        > > it to
        > >
        > >> load dynamically, that will happen asynchronously. If you need
        to do
        > >> things with the nodes once they get loaded, listen to the
        > >>
        > > expandComplete
        > >
        > >> event.
        > >>
        > >> Satyam
        > >>
        > >>
        > >> matthew_be wrote:
        > >>
        > >>> Hi,
        > >>>
        > >>> When a user clicks on a link of my webpage,
        > >>> I would like to expand automatically a specific leaf in my tree.
        > >>>
        > >>> How can I achieve this ?
        > >>>
        > >>> I tried to use the 'expand' function of the nodes where this leaf is
        > >>> located, but the problem is that the expand function is
        asynchronous :
        > >>>
        > >>> var gem = root.children[1];
        > >>> if(!gem.expanded) gem.expand();
        > >>> alert(gem.children.length); // displays 0 because the children are
        > >>> loaded asynchronously
        > >>>
        > >>> Thank you for any help ... !
        > >>>
        > >>>
        > >>> ------------------------------------
        > >>>
        > >>> Yahoo! Groups Links
        > >>>
        > >>>
        > >>>
        > >>>
        > >>>
        > >
        ------------------------------------------------------------------------
        > >
        > >>> No virus found in this incoming message.
        > >>> Checked by AVG - http://www.avg.com
        > >>> Version: 8.0.169 / Virus Database: 270.6.13/1642 - Release Date:
        > >>>
        > > 29/08/2008 18:12
        > >
        > >>>
        > >
        > >
        > >
        > > ------------------------------------
        > >
        > > Yahoo! Groups Links
        > >
        > >
        > >
        > >
        ------------------------------------------------------------------------
        > >
        > >
        > > No virus found in this incoming message.
        > > Checked by AVG - http://www.avg.com
        > > Version: 8.0.169 / Virus Database: 270.6.13/1642 - Release Date:
        29/08/2008 18:12
        > >
        > >
        >
      • Satyam
        On the other hand, if you expand and/or collapse a node in several places, in jQuery you have to repeat your callback every time and in YUI only once. In YUI
        Message 3 of 6 , Aug 31, 2008
        • 0 Attachment
          On the other hand, if you expand and/or collapse a node in several
          places, in jQuery you have to repeat your callback every time and in YUI
          only once. In YUI it would be like saying, whenever this happens, no
          matter what caused it, I want this to happen. I can't say any way is
          better than the other and, yes, it is more than just syntax, but either
          way is fine and either way can have its pros and cons.

          Anyway, if you try to carry over your experience with one way of doing
          things to another way of doing them, you would miss something and would
          keep struggling to make one way of doing things into another way.. I am
          sure there is a better way than using setTimeout, but that's your
          choice, if that works for you, that's fine.

          Satyam

          matthew_be wrote:
          > I do not think it is just a matter of syntax:
          >
          > When the user clicks on a specific link in my web app,
          > I want to expand a node in my tree.
          >
          > If I use the exandComplete callback function,
          > this code will be executed for every expandComplete events.
          > In jQuery I can bind a callback function for one specific asynchronous
          > call.
          >
          > I'll have to stick with the setTimeout function and test the
          > dynamicLoadComplete variable.
          >
          >
          > --- In ydn-javascript@yahoogroups.com, Satyam <satyam@...> wrote:
          >
          >>
          >> matthew_be wrote:
          >>
          >>> Thank you for your support!
          >>>
          >>> If I understood, you were talking about the function called once the
          >>> data is loaded:
          >>> tree.setDynamicLoad(loadNodeData, currentIconMode);
          >>>
          >>>
          >>>
          >> Actually, no, that is a function to be called in order to load nodes,
          >> not once it is loaded. Anyway, if you didn't use it, that cannot be
          >>
          > the
          >
          >> problem.
          >>
          >>> Unfortunately I don't know how to pass a variable in this callback
          >>> function which could allow me to check what needs to be done.
          >>>
          >>>
          >> That is what event listeners are there for. You tell what event you
          >> want to listen to and provide a function (callback) that will handle
          >> it. The expandComplete event which I mentioned is one such. If you
          >> used them jQuery style, then it is just a matter of handling a
          >>
          > different
          >
          >> syntax. In YUI you order the node expanded and you listen for the
          >> signal that it has been completed, but you do that in two separate
          >>
          > calls.
          >
          >> Satyam
          >>
          >>
          >>> I wish there was a callback function triggered when the node is
          >>> expanded, jQuery-style:
          >>> node.expand(function() { ... });
          >>> (jQuery provides callback functions for most of the asynchronous
          >>>
          > events)
          >
          >>> Anyway I found a solution to my problem :
          >>> check dynamicLoadComplete property, once it is set to true,
          >>> continue code ... couldn't find another solution
          >>>
          >>> function clickGemeente(gemeente) {
          >>> tree = YAHOO.widget.TreeView.getTree("op");
          >>> var root = tree.getRoot();
          >>> var gem = root.children[1];
          >>> if(!gem.expanded) gem.expand();
          >>> expandGem(gem, gemeente);
          >>> }
          >>>
          >>> function expandGem(gem, gemeente) {
          >>> if(!gem.dynamicLoadComplete)
          >>> setTimeout( function(){ expandGem(gem, gemeente) }, 200);
          >>> else {
          >>> for (var i=0, j=gem.children.length; i<j; i++) {
          >>> var node = gem.children[i];
          >>> if(node.data.label == gemeente) {
          >>> $.scrollTo( $('#' + node.getElId()) );
          >>> node.expand();
          >>> break;
          >>> }
          >>> }
          >>> }
          >>> }
          >>>
          >>>
          >>>
          >>>
          >>> --- In ydn-javascript@yahoogroups.com, Satyam <satyam@> wrote:
          >>>
          >>>
          >>>> If you ask to load nodes dynamically, dynamic loading will be done
          >>>> asynchronously, if the nodes were already loaded, there will be no
          >>>> delay. Nothing the expand method can do much about. If you asked
          >>>>
          >>>>
          >>> it to
          >>>
          >>>
          >>>> load dynamically, that will happen asynchronously. If you need
          >>>>
          > to do
          >
          >>>> things with the nodes once they get loaded, listen to the
          >>>>
          >>>>
          >>> expandComplete
          >>>
          >>>
          >>>> event.
          >>>>
          >>>> Satyam
          >>>>
          >>>>
          >>>> matthew_be wrote:
          >>>>
          >>>>
          >>>>> Hi,
          >>>>>
          >>>>> When a user clicks on a link of my webpage,
          >>>>> I would like to expand automatically a specific leaf in my tree.
          >>>>>
          >>>>> How can I achieve this ?
          >>>>>
          >>>>> I tried to use the 'expand' function of the nodes where this leaf is
          >>>>> located, but the problem is that the expand function is
          >>>>>
          > asynchronous :
          >
          >>>>> var gem = root.children[1];
          >>>>> if(!gem.expanded) gem.expand();
          >>>>> alert(gem.children.length); // displays 0 because the children are
          >>>>> loaded asynchronously
          >>>>>
          >>>>> Thank you for any help ... !
          >>>>>
          >>>>>
          >>>>> ------------------------------------
          >>>>>
          >>>>> Yahoo! Groups Links
          >>>>>
          >>>>>
          >>>>>
          >>>>>
          >>>>>
          >>>>>
          > ------------------------------------------------------------------------
          >
          >>>
          >>>
          >>>>> No virus found in this incoming message.
          >>>>> Checked by AVG - http://www.avg.com
          >>>>> Version: 8.0.169 / Virus Database: 270.6.13/1642 - Release Date:
          >>>>>
          >>>>>
          >>> 29/08/2008 18:12
          >>>
          >>>
          >>>>>
          >>>>>
          >>>
          >>> ------------------------------------
          >>>
          >>> Yahoo! Groups Links
          >>>
          >>>
          >>>
          >>>
          >>>
          > ------------------------------------------------------------------------
          >
          >>> No virus found in this incoming message.
          >>> Checked by AVG - http://www.avg.com
          >>> Version: 8.0.169 / Virus Database: 270.6.13/1642 - Release Date:
          >>>
          > 29/08/2008 18:12
          >
          >>>
          >
          >
          >
          > ------------------------------------
          >
          > Yahoo! Groups Links
          >
          >
          >
          > ------------------------------------------------------------------------
          >
          >
          > No virus found in this incoming message.
          > Checked by AVG - http://www.avg.com
          > Version: 8.0.169 / Virus Database: 270.6.13/1642 - Release Date: 29/08/2008 18:12
          >
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.