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

Re: [ydn-javascript] YUI widget render time and order? & treeview dynamic load

Expand Messages
  • Satyam
    1) You can call render at any time. Whatever nodes exist in the tree up to that point will be rendered. Nodes added later (unless via dynamic loading) will
    Message 1 of 2 , Dec 15, 2009
    • 0 Attachment
      1) You can call render at any time. Whatever nodes exist in the tree up
      to that point will be rendered. Nodes added later (unless via dynamic
      loading) will not be rendered (except a few exceptions such as
      grandchildren of collapsed nodes). If you call render again, those
      newly added nodes (after the previous render) will be rendered. In
      YUI2 there are no generic rules about calling render. Since it was
      developed over a long period, later components behave different (and
      better) than older ones. TreeView is one of the oldest. Don't take its
      behavior as a model for other components.

      2) I have the feeling that you meant to have your function named
      callback called instead of the one passed to the dynamic loader as an
      argument. This will not happen as, within the dynamic loader, the
      argument called 'callback' would hide anything but that name elsewhere
      in your code.

      What you want to do is to listen to the collapseComplete event (better
      than collapse, since it is fired once the node is collapsed). Then,
      after removing the node's children as you've done you have to set the
      dynamicLoadComplete flag to false again:

      http://developer.yahoo.com/yui/docs/YAHOO.widget.Node.html#property_dynamicLoadComplete

      If left set to true, TreeView will think it has already loaded all there
      was to be loaded. A node with no children does not mean it has any
      pending loads to do.

      Satyam

      janwen escribió:
      >
      >
      > 1.i just finish the search on the YDN group for this question,but i do
      > not get the answer i want.my question is:Almost all YUI(yui2) widgets
      > have the method render(),when i use treeview widget,i am not sure when
      > is exactly time to render a tree and when i read the treeview tutorial
      > on YUI treeview component,the time & order render the component or
      > widget is very important.i just receive a reply from YUI library
      > forums by Satyam(thanks),
      > http://yuilibrary.com/forum/viewtopic.php?f=89&t=1008&p=6692#p6692,
      > <http://yuilibrary.com/forum/viewtopic.php?f=89&t=1008&p=6692#p6692,>
      > in his reply, he also tell me the important of a component render time.
      > 2.the #2 question is, i set a tree with dynamic load function,my
      > intention is hope when the user collapse a node then the node load the
      > data again when the user expand the node again,i get the method from
      > tutorial:tree.removeChildren(nodeToReset); i set it on my tree,but it
      > seems not work:
      > following is the snippet of my code:
      > var dynamicNode = new YAHOO.widget.TextNode({label:"dynamic
      > node",id:4},oTreeView.getRoot(),false);
      > dynamicNode.setDynamicLoad(loadData);
      >
      > function loadData(node,callBack){
      > ; //console.warn("loading data");
      > var tempNode;
      > for(var i=0;i<300;i++){
      > tempNode = new
      > YAHOO.widget.TextNode("DynamicNode-" + i,node,false);
      > }
      > callBack(node);
      > }
      > function callBack(node){
      >
      > //console.warn("load data completetion");
      > &n bsp; }
      > dynamicNode.subscribe("collapse", function(node){
      > console.warn("collapse node");
      > tree.removeChildren(node);
      > });
      >
      > thanks all
      >
      >
      >
      >
      >
      >
      >
      >
      > ------------------------------------------------------------------------
      >
      >
      > No virus found in this incoming message.
      > Checked by AVG - www.avg.com
      > Version: 9.0.716 / Virus Database: 270.14.107/2564 - Release Date: 12/14/09 08:37:00
      >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.