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

Re: trying again :/ ...null element returned for treeview dynamic nodes

Expand Messages
  • ozgursusoy
    ... alert( elementFromDoc: +document.getElementById(nodeToSelect.getElId())); ... ok, worked it out, was trying to use expandComplete as an event automatically
    Message 1 of 2 , Jun 30, 2008
    • 0 Attachment
      --- In ydn-javascript@yahoogroups.com, "ozgursusoy" <ozgursusoy@...>
      > bit disappointed with no responses to this:
      > i'm using a treeview where all nodes (except root) are generated by
      > dynamic loading. when the user makes additions/modifications/deletions
      > to data represented by a node on the treeview, i use
      > removeChildren(parentNode) and parentNode.expand() to refresh the
      > necessary nodes. once the treeview is refreshed, i need to either
      > reselect the original node(when edited), new node(when added) or a
      > sibling/parent(when deleted).
      > original problem i had was the expandComplete event firing before the
      > child nodes are generated, let alone parent node getting expanded.
      > easily worked around that by using a custom event fired from the
      > function that generates the new nodes.
      > however, still having problems with trying to scroll the panel
      > containing the treeview to make sure the newly selected node is
      > visible on the screen. The problem seems to be in referencing the
      > dynamically generated element representing the selected node. both
      > getEl() and getLabelEl() are returning null even thought the node has
      > an element id!!, below is my handler for the custom event fired once
      > nodes are generated:
      > var onUpdateNodeLoad = function (type, args){
      > _tree.dynamicLoadCompleteEvent.unsubscribe() ;
      > nodeToSelect = _tree.getNodeByProperty(keyField, keyToSelect) ;
      > //this returns an id, ie.'ygtv15'
      > alert("elementID:"+nodeToSelect.getElId( ));
      > //this returns null!
      > //also returns null
      > alert("elementFromGetEl: " + nodeToSelect.getEl());
      > //so this doesn't work! nodeToSelect.getEl().scrollIntoView() ;
      > }
      > same results if i use getLabelEl() instead of getEl()!
      > i think this might be happening because the parent node still hasn't
      > finished expanding when the custom event is fired but how would i get
      > around that considering expandComplete is useless in this case?!
      > this is getting used for a commercial project so any ideas would be
      > much appreciated.

      ok, worked it out, was trying to use expandComplete as an event
      automatically fired when a node is expanded! didn't realise i had to
      subscribe to it :/ thanx. for others who might run into this prob:

      _tree.subscribe("expandComplete", function (node, arg) {
      if (node == nodeToExpand){

      //some processing

    Your message has been successfully submitted and would be delivered to recipients shortly.