@@ -764,12 +764,10 @@ void createItem (TreeItem item, Object hParent, int index) {
764764 items = new TreeItem [0 ];
765765 }
766766
767- boolean isAppending = false ;
768767 TreeItem [] itemList = (hParent == null ? directChildrens : item .parentItem .items );
769768 int idx = -1 ;
770769 if (index < 0 || index >= itemList .length ) {
771770 //append
772- isAppending = true ;
773771 if (hParent == null ) {
774772 idx = items .length ;
775773 } else {
@@ -779,7 +777,7 @@ void createItem (TreeItem item, Object hParent, int index) {
779777 } else {
780778 idx = findSiblingNextItem (item .parentItem .index );
781779 if (idx != -1 ) {
782- idx --;
780+ // idx--;
783781 } else {
784782 idx = items .length ;
785783 }
@@ -791,7 +789,7 @@ void createItem (TreeItem item, Object hParent, int index) {
791789 // insert
792790 idx = findSiblingNextItem (itemList [index ].index );
793791 if (idx != -1 ) {
794- idx --;
792+ // idx--;
795793 } else {
796794 idx = items .length ;
797795 }
@@ -802,7 +800,7 @@ void createItem (TreeItem item, Object hParent, int index) {
802800 }
803801 for (int i = items .length - 1 ; i >= idx ; i --) {
804802 items [i + 1 ] = items [i ];
805- items [i + 1 ].index = i ;
803+ items [i + 1 ].index = i + 1 ;
806804 }
807805 items [idx ] = item ;
808806 item .index = idx ;
@@ -838,10 +836,10 @@ void createItem (TreeItem item, Object hParent, int index) {
838836 tbody .childNodes [0 ].className = "" ; // remove tree-row-first!
839837 }
840838 }
841- if (isAppending ) {
839+ if (idx >= items . length ) {
842840 tbody .appendChild (tbodyTR );
843841 } else {
844- tbody .insertBefore (tbodyTR , tbody .childNodes [index ]);
842+ tbody .insertBefore (tbodyTR , tbody .childNodes [idx ]);
845843 }
846844
847845 Element td = document .createElement ("TD" );
@@ -887,7 +885,7 @@ void createItem (TreeItem item, Object hParent, int index) {
887885 cssClass += " tree-anchor-single" ;
888886 }
889887 } else {
890- cssClass += " tree-anchor-single " ;
888+ cssClass += " tree-anchor-middle " ;
891889 }
892890 } else if (hParent != null && i == 0 ) {
893891 cssClass += " tree-anchor-end" ;
@@ -930,7 +928,7 @@ void createItem (TreeItem item, Object hParent, int index) {
930928 tbodyTR .appendChild (td );
931929
932930 if (item .parentItem != null ) {
933- item .parentItem .addItem (item , index );
931+ // item.parentItem.addItem(item, index);
934932 //item.parentItem.setExpanded(false);
935933// item.parentItem.setExpanded(item.parentItem.getExpanded());
936934// item.handle.style.display = "none";
@@ -996,7 +994,10 @@ public void run() {
996994 item = item .parentItem ;
997995 }
998996 if (!visible ) {
999- tbodyTR .style .display = "none" ;
997+ /*
998+ * Developer can comment the following line to show all tree nodes expanded
999+ */
1000+ tbodyTR .style .display = "none" ;
10001001 }
10011002}
10021003
0 commit comments