Disabling treeview events

Last post 11-26-2009 1:18 PM by mohi. 5 replies.

Sort Posts:

  • Disabling treeview events

    07-23-2006, 10:14 PM
    • Member
      20 point Member
    • pmccoy
    • Member since 07-24-2006, 1:55 AM
    • Posts 4

    Thanks to anyone that can help me with this.  Before laying out the problem I'm having, I should mention that my project is a web part designed for a Sharepoint Portal.  From what I can tell, that limits me to a non-visual implementation of the treeview and forces me to do everything in a sort of a "code behind" page.

    With that said, I have been able to successfully implement the treeview into a web part and it works quite well.  The issue I'm having is that the code that generates my tree takes a little while to run and I'd like to minimize the number of postbacks.  More specifically, I would like to limit postbacks to "selectedindexchanged" events only.  The problem is that this control appears to be "all or nothing" in terms of events.  In other words, if I set autopostback to "false", I can't get the selectedindexchanged event to fire.  If I set autopostback to "true", I get a postback on node expand and collapse events as well as the index changed event.

    So, the question is... can I:

    - somehow manually force a postback for the selectedinexchanged event when the autopostback is set to "false" or...

    - somehow disable the postback for the expand/collapse events when the autopostback is set to "true"?

    - Pete

  • Re: Disabling treeview events

    07-24-2006, 9:42 AM
    • Member
      20 point Member
    • pmccoy
    • Member since 07-24-2006, 1:55 AM
    • Posts 4
    Never mind... I found a post about how to do this by modifying the htc files.  Thanks to those that have posted the htc file modifications!
  • Re: Disabling treeview events

    08-01-2006, 12:37 AM
    • Member
      5 point Member
    • vishalDotNet
    • Member since 08-01-2006, 4:31 AM
    • Posts 1

    hi brother ,

     

    i am also facing the same issue , could you please help me to come out of it or gimme the link of he post that solved your issue.

  • Re: Disabling treeview events

    08-01-2006, 8:46 AM
    • Member
      20 point Member
    • pmccoy
    • Member since 07-24-2006, 1:55 AM
    • Posts 4

    This link has several solutions: http://forums.asp.net/thread/469254.aspx

    The best one I found was offered by persky.  To use it, backup the treeview.htc file and then open it with notepad or some other text editor.  Find the function "nodePlusMinusClick" and replace the entire function with the following code: 

    function nodePlusMinusClick()
    {
    if (g_bInteractive == false)
    return;
    var el = this.parentElement.treenode;
    // 2 lines below commented out to disable postback on expand/collapse, extra lines added below for better functionality
    // if (doNodePlusMinusClick(el) == true)
    //     fireQueuedEvents();
    var index = getNodeIndex(el);
    // if the selected or hovered node was one of the collapsed node's descendants then postback anyway
    if (selectedNodeIndex.length > index.length && selectedNodeIndex.substr(0,index.length) == index)
    {
    if (doNodePlusMinusClick(el) == true)
    fireQueuedEvents();
    }
    // otherwise just do the expand/collapse stuff
    else
    doNodePlusMinusClick(el);
    }
     
  • Re: Disabling treeview events

    11-01-2007, 9:22 AM
    • Member
      2 point Member
    • ashwn_acharya
    • Member since 05-16-2007, 12:22 PM
    • Posts 1

    Hi,

        You can disable postbacks  for expand/collapse events by Setting the property TreeNode.SelectAction = TreeNodeSelectAction.Expand. This will cause the treenodes to expand/collapse without a postback. If you want to enable postback for a particular node, set the property TreeNode.SelectAction = TreeNodeSelectAction.Select or TreeNodeSelectAction.SelectExpand.

    I hope this solves your problem. Cheers!!! 

  • Re: Disabling treeview events

    11-26-2009, 1:18 PM
    • Member
      4 point Member
    • mohi
    • Member since 11-25-2009, 2:34 PM
    • Posts 8

    thanks that worked

Page 1 of 1 (6 items)