Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
815
Sorting Child Nodes
posted

I am looking for a way to sort only certain Child nodes.

Example Tree:  The top level categories should be manually sorted while the items should be in alpha order.

  • Most Common Items
    • Item 1
    • Item 2
    • Item 3
  • Less Common Items
    • Item 4
    • Item 5
    • Item 6
  • Other Items
    • Item 7 

I originally set the .Override.Sort property to the category nodes to Ascending but that didn't appear to have any effect. I have also tried to use columnsets but even with manually clicking on the column headers sorting never changed.  The direction arrow flipped but the data never moved.  I am using 2007 vol 3.

  • 469350
    Offline posted

     I think Frans is thinking of UltraWinGrid. UltraWinTree doesn't have "bands".

    The solution to your problem is to use a different Override. The Override on the tree control affects all the nodes in the tree. But there are also Overrides on the Nodes collection. So what you would do is set the Sort property on the nodes collection of each parent node instead of on the tree's override.

    • 815
      Offline posted in reply to Mike Saltzman

      Mike, thanks for the clarification. Though that describes what I am trying to do.  The Treeview.Override.Sort has been set to Default.  ViewStyle = Standard.  Here is my code below.  Note that I am setting the Node.Override.Sort = Ascending.  Anything that you can see

      ' Code to add the Categories Nodes

      Dim oStartNode As UltraTreeNode
      oStartNode = utvItems.GetNodeByKey("MasterOrder")

      With oStartNode.Nodes


      Dim oNewNode As New UltraTreeNode(String.Format("MO{0}", JobID), JobName)
      oNewNode.Override.ActiveNodeAppearance.FontData.Bold = DefaultableBoolean.True
      oNewNode.Override.NodeAppearance.Image = My.Resources.FolderClosed_Small
      oNewNode.Override.ExpandedNodeAppearance.Image = My.Resources.FolderOpen_Small
      oNewNode.Override.Sort = SortType.Ascending
      .Add(oNewNode)


      End With

      ' Code to add each Item to the Categories

      Dim oCatNode As UltraTreeNode
      oCatNode = utvItems.GetNodeByKey(String.Format("MO{0}", JobID))

      With oCatNode.Nodes

      Dim oNewNode As New UltraTreeNode(String.Format("I{0}", dr("iItemID").ToString), String.Format("{0} - {1}", dr("sEPICCode").ToString, dr("sItemDesc").ToString))

      oNewNode.Override.NodeAppearance.Image = My.Resources.Green_48
      oNewNode.Override.ActiveNodeAppearance.FontData.Bold = DefaultableBoolean.True

      .Add(oNewNode)

      End With

      • 815
        Verified Answer
        Offline posted in reply to Mike Saltzman

        Eureka.  It finally sunk in.  Here is what I needed to do.

        When I was creating the 'category' nodes I was setting the sort override like this:

        oNewNode.Override.Sort = Ascending (as you mentioned this is worthless and does nothing)

        it needed to be

        oNewNode.Nodes.Override.Sort = Ascending.

         

        Thank you for your help.  Knew it was something simple that I was just overlooking.

        • 469350
          Offline posted in reply to Eric Rupp

          I'm really not sure I understand what you are trying to do. The Sort property exists on the Override. That means you can set it many different levels. There is an Override on the tree control itself - this will affect all nodes in the tree.

          There is an Override on every Nodes collection that will affect all the nodes in that collection.

          There is an Override on the Node itself, which will only affect a single node - this obviously has no effect on sorting, since it makes no sense to sort a single node, but there are other properties on the Override that apply.

          There is also the NodeLevelOverrides collection, which allows you to apply settings to a particular level. For example, NodeLevelOverrides(0) would  affect all root-level nodes. NodeLevelOverrides[1] would affect all nodes that are direct children of the root.

          • 815
            Offline posted in reply to Mike Saltzman

            Ok, I tried your solution.  Unfortuantely there was no change in the behavior.  Question about the solution:

            Basically what I am doing is loading the treeview with the second level folders.  As I load them I set the .Override.Sort = Ascending.  From a second procedure I load the third level which are the nodes that I want to have sorted.  From your response it would appear that I should set the Override.Sort on the FIRST level, not the SECOND.  Is that correct?

            Could this be a control property problem?  Such as the ViewState? Also, I am calling the RefreshSort method just after I complete the load of all items.  Should I not do this?

            Thanks again for your attention and patience.

            • 469350
              Verified Answer
              Offline posted in reply to Eric Rupp

              Well, you are setting Sort on the Node, not the Nodes collection. You are essentially sorting a single node, which of course has no meaning.

               I think you need to change:

              oNewNode.Override.Sort = SortType.Ascending

              to

              .Override.Sort = SortType.Ascending

          • 120
            posted
            Hello hydroeric,

            You may be able to do this by setting the override.sort for the band to alphanumeric
            then overriding each of the root level nodes with the sort for the common
            property.

            Alternatively, set override.sort for the band to alphanumeric and manually
            quicksort the top-level items using node.reposition.

            Cheers,
            Frans Henskens

            > I am looking for a way to sort only certain Child nodes.
            >
            > Example Tree: The top level categories should be manually sorted
            > while the items should be in alpha order.
            >
            > Most Common Items
            >
            > Item 1
            > Item 2
            > Item 3
            > Less Common Items
            > Item 4
            > Item 5
            > Item 6
            > Other Items
            > Item 7
            >
            > I originally set the .Override.Sort property to the category nodes to
            > Ascending but that didn't appear to have any effect. I have also tried
            > to use columnsets but even with manually clicking on the column
            > headers sorting never changed. The direction arrow flipped but the
            > data never moved. I am using 2007 vol 3.
            >
            • 815
              Offline posted in reply to Adam

              Franz thanks for the speedy response.  Sorry to say that I am confused by your answer. 

              You mentioned "setting the override.sort for the band to alphanumeric"  How is that accomplished?  I could not find a BAND property.  Also when setting the Sort property the choices I can see are Ascending, Descending, None, and Default.  Did you mean Ascending?

               

              Thanks in advance,

              Eric