Sorting tree items manually

Ask a Question related to Coldfusion Flash Integration, Design and Development.

  1. #1

    Default Sorting tree items manually

    I am trying to allow the user a way of shifting through items in a tree 2
    levels deep. This will give the user a chance to order the items within the
    tree so they can be sent to word in the desired sequence. I have working code
    for shifting through items at the lowest level but I can't get it to work
    correctly for the folder level items. I have some code that works okay but has
    a little problem. I found that if you stick with moving one folder up the tree
    then you won't encounter the problem. However, if you switch to a different
    folder to move then you will encounter the problem sooner. The problem seems to
    be copying a portion of the tree and appending it to the end. I don't know what
    exactly is happening! I was hoping that someone could help me out on this.

    Does anybody know a way to do this? Ohh yeah and I would like the
    selectedIndex to stay with the folder selected as well.

    (I also posted this in the ?Advanced Techniques? forum.)

    Thanks for your help.

    Jeff

    Code:

    function treeSortUp(tree, Changeprogram){
    if(tree.selectedIndex != undefined && tree.selectedIndex != 0){
    var folderOpenArray:Array = [0];
    for(var i=0; i<tree.getLength(); i++){
    var thisNode1 = tree.getTreeNodeAt(i);
    folderOpenArray[i] = tree.getIsOpen(thisNode1);
    tree.setIsOpen(thisNode1, true);
    }

    var Index = tree.selectedIndex;
    var First = tree.getNodeDisplayedAt(Index-1);
    var Second = tree.getNodeDisplayedAt(Index);

    if(tree.getIsBranch(Second) == true){
    for(var i=0; i<tree.getLength(); i++){
    if(tree.selectedNode == tree.getTreeNodeAt(i)){
    <!---alert('Second: '+tree.getTreeNodeAt(i).getProperty('label')+'
    First: '+tree.getTreeNodeAt(i-1).getProperty('label'));--->
    tree.addTreeNodeAt(i-1, tree.getTreeNodeAt(i));
    tree.removeTreeNodeAt(i+1);
    break;
    }
    if(tree.getTreeNodeAt(Index) == tree.getTreeNodeAt(i);
    <!--- the selected index is not working correctly --->
    tree.selectedIndex = i-1;
    }
    }
    }else if(tree.getIsBranch(First) == false || Changeprogram == 'yes'){
    tree.addItemAt(Index-1, Second);
    tree.addItemAt(Index, First);
    tree.removeItemAt(Index+1);
    tree.removeItemAt(Index+1);
    tree.selectedIndex = Index-1;
    }

    for(var i=0; i<tree.getLength(); i++){
    var thisNode1 = tree.getTreeNodeAt(i);
    tree.setIsOpen(thisNode1, folderOpenArray[i]);
    }
    }
    }

    jedale Guest

  2. Similar Questions and Discussions

    1. coloring items in a tree
      I have a tree that uses a cell renderer to change the font color of the tree. The only time the items actually change colors is when the mouse goes...
    2. Flex Tree data sorting
      Did anybody try to sort data in flex tree in alphabetical order??? HOw to do it? I have just a number of groups (root nodes) and a number if...
    3. client side sorting of datagrid items
      Does anyone know if there's code out there to manage client-side sorting of datagrid items? I'd like to be able to fill a datagrid with records...
    4. Array Sorting, 2 items...
      Hi, Trying to accomplish: I want to sort my array by two columns. The array is setup: Array ( => Array (
    5. [PHP] Array Sorting, 2 items...
      > -----Original Message----- Well, erm, maybe I've got the wrong glasses on today, or maybe you've made a cut'n'paste boo-boo, but it sure looks...
  3. #2

    Default Re: Sorting tree items manually

    Has Anybody even attempted this before?
    jedale Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139