TreeNodes - Soemtimes postback sometimes do not

Discussion in 'ASP .Net Web Controls' started by RodBillett, Dec 8, 2003.

  1. RodBillett

    RodBillett Guest

    In out application, we wanted to limit the number of treenodes for any given
    parent treenode. and we wanted the user to be able to "more" to the
    additional (not shown nodes). When the user selected an item (not the more)
    the hyperlink was executed, and no postback was incurred, but when they
    press the more or previous, a postback occurs and the server code can
    refresh the treenodes list. This accomplished 2 things. 1) It eliminated
    the 'flicker' caused by the repeated postbacks whenver the mouse is clicked
    in the treeview and 2) it reduced the amount of information passed in the
    HTML (Viewstate and such) back down to the client.

    Through some changes to the Server side controls and the htc files I was
    able to accomplish this. I thought others might like to see how this was
    done, and alos post up for any problems that I might have introduced. My
    appologies, but this was my first attempt at programming IE behaviors so if
    I could have done it cleaner - i would like suggestions too!

    the UI looked like this

    Treeview
    TreeNode1
    PreviousTreeNode1Items
    TreeNode1Item4
    TreeNode1Item5
    TreeNode1Item6
    MoreTreeNode1Items
    TreeNode2
    ...
    Within your application code, create a TreeNodeType with a type of "MORE".
    Then if you have a Previous or More condition in the treenode, add a node at
    the beginning or end with this nodetype (and implement the SelectedIndex
    Changed event for the treeview). Use the NodeData property to store the
    information needed to perform the more or previous navigation.

    Within the treeview.cs file, I commented out the following line of code
    within the RenderUpLevelPath() method
    // output.AddAttribute("onselectedindexchange", "javascript:" + " if
    (event.oldTreeNodeIndex != event.newTreeNodeIndex)
    this.queueEvent('onselectedindexchange', event.oldTreeNodeIndex + ',' +
    event.newTreeNodeIndex)");

    I then added the following code to the Treeview.htc within the
    doNodeClick(el) method. (First part of If statement was already there.

    if (getNodeAttribute(el, "NavigateUrl") != null)
    {
    var target = getNodeAttribute(el, "Target");
    if (target == null || target.toLowerCase() == "_self")
    return false;
    }
    else
    {
    var ThisNodeType = getNodeAttribute(el, "TYPE");
    if ( ThisNodeType != null)
    {
    if ( ThisNodeType == "more" )
    {
    this.queueEvent('onselectedindexchange', '0,' +
    getNodeIndex(el) );
    fireQueuedEvents();
    return false;
    }
    }
    }

    hope this helps other!
    Rod
     
    RodBillett, Dec 8, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nehmo Sergheyev
    Replies:
    1
    Views:
    515
    Andrew Urquhart
    May 9, 2004
  2. Marcin Vorbrodt

    ::std sometimes needed, sometimes not

    Marcin Vorbrodt, Sep 16, 2003, in forum: C++
    Replies:
    24
    Views:
    783
    Jerry Coffin
    Sep 17, 2003
  3. Replies:
    1
    Views:
    514
    gkelly
    Nov 29, 2006
  4. rune solheim
    Replies:
    0
    Views:
    246
    rune solheim
    Sep 24, 2003
  5. Kamyk
    Replies:
    2
    Views:
    188
    Thomas 'PointedEars' Lahn
    May 8, 2005
Loading...

Share This Page