accessing subnodes in TreeView from javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Johan Åhlén

    #1

    accessing subnodes in TreeView from javascript


    Hi,

    Does anybody have any idea how to access child nodes in a TreeView
    without using postbacks?

    For example: in the subtree below I want to disable nodes B, C and D
    when A is checked (and enable them again when A is unchecked):

    Subtree:
    [ ]A---[ ]B
    |----[ ]C
    |----[ ]D

    I want to do this entirely in javascript. Any idea how to access the state
    of the child nodes from the eventhandlers?

    Thanks for any help!

    Johan

    ---
    Johan Åhlén
    Bostadstips Sverige AB
    Email: johan@NObostads tipsSPAM.com <-- remove NOSPAM to email me
    Web: http://www.bostadstips.com
    Tel +46 31 842500


  • Johan Åhlén

    #2
    Re: accessing subnodes in TreeView from javascript


    Hi again,

    Accessing the child nodes wasn't that much of a problem. The bigger problem
    was
    disabling them, which required (from what I have found) making changes in
    the
    control itself, to support a new attribute - "disabled".

    Here is the the resulting code:

    Add eventhandler:
    oncheck="javasc ript: if (this.clickedNo deIndex != null)
    __disableChildN odes(this);"

    // Select and disable all child nodes under the recently clicked node
    function __disableChildN odes( tree )
    {
    var node = tree.getTreeNod e(tree.clickedN odeIndex);
    var state = node.getAttribu te('checked');

    __setChildNodes State( node, state );
    }

    function __setChildNodes State( node, state )
    {
    var children = node.getChildre n();

    if ( children[0] != undefined )
    {
    for (var i = 0; i < children.length ; i++)
    {
    children[i].setAttribute(' checked',state) ;
    children[i].setAttribute(' disabled',state );
    __setChildNodes State( children[i], state );
    }
    }
    }


    "Johan Åhlén" <johan@NObostad stipsSPAM.com> wrote in message
    news:ehReoanYDH A.2424@TK2MSFTN GP12.phx.gbl...[color=blue]
    >
    > Hi,
    >
    > Does anybody have any idea how to access child nodes in a TreeView
    > without using postbacks?
    >
    > For example: in the subtree below I want to disable nodes B, C and D
    > when A is checked (and enable them again when A is unchecked):
    >
    > Subtree:
    > [ ]A---[ ]B
    > |----[ ]C
    > |----[ ]D
    >
    > I want to do this entirely in javascript. Any idea how to access the state
    > of the child nodes from the eventhandlers?
    >
    > Thanks for any help!
    >
    > Johan
    >
    > ---
    > Johan Åhlén
    > Bostadstips Sverige AB
    > Email: johan@NObostads tipsSPAM.com <-- remove NOSPAM to email me
    > Web: http://www.bostadstips.com
    > Tel +46 31 842500
    >
    >[/color]


    Comment

    Working...