I've been playing around with the Treenode widget and I have a problem. I
build 2 trees dynamically from data pulled from a database. That works
great. But when I try to add a selected child from one tree to the other, it
does nothing. I don't get an error but the new node doesn't show up in the
other tree. Anyone?
The code recurses the tree to find where it has to start adding from.
Jon
------------------------------------------------
var theme = "/dynapi/images/themes/treeview/";
document.write('<script language="Javascript"
src="'+theme+'style.js"><'+'/'+'script>');
DynAPI.setLibraryPath('/dynapi/js/lib/');
DynAPI.include('dynapi.api.*');
DynAPI.include('dynapi.ext.images.js')
DynAPI.include('dynapi.ext.inline.js')
DynAPI.include('dynapi.ext.debug.js')
DynAPI.include('dynapi.jon.fasttreenode.js'); // I've modified some of the
code. Mostly just added attributes for the app I'm working on.
DynAPI.include('dynapi.jon.thread.js');
DynAPI.include('dynapi.jon.pathanim.js');
DynAPI.include('dynapi.gui.sprite.js')
DynAPI.include('dynapi.gui.viewport.js')
DynAPI.include('dynapi.gui.buttonimage.js')
DynAPI.include('dynapi.gui.scrollbar.js')
DynAPI.include('dynapi.gui.scrollpane.js')
MetalScrollPaneURL = DynAPI.librarypath+"../images/scrollpane/";
DynAPI.onLoad = function()
{
// Just here to position the scrollers.
all_tags = DynAPI.document.all["allTagsDiv"];
add_tags = DynAPI.document.all["addTagsDiv"];
scroller1 = new ScrollPane();
scroller1.setSize( 195,300 );
scroller1.moveTo( all_tags.getX()-3, all_tags.getY()-3 );
scroller2 = new ScrollPane();
scroller2.setSize( 195,300 );
scroller2.moveTo( add_tags.getX()-3, add_tags.getY()-3 );
DynAPI.document.addChild(scroller1);
DynAPI.document.addChild(scroller2);
all0 = new JonTreenode(0,0,100,null,'Root',theme,20);
all0.setColor('#FFFFCE');
add0 = new JonTreenode(0,0,100,null,'Root',theme,20);
add0.setColor('#FFFFCE');
all1=all0.add('Sports', 1, 0, 1, 1);
all8=all1.add('Baseball', 8, 1, 2, 1);
all17=all1.add('Basketball', 17, 1, 2, 1);
all3=all1.add('Bowling', 3, 1, 2, 1);
all4=all1.add('Football', 4, 1, 2, 1);
all14=all1.add('Golf', 14, 1, 2, 1);
all18=all1.add('Gymnastics', 18, 1, 2, 1);
all9=all1.add('Hockey', 9, 1, 2, 1);
all16=all1.add('Tennis', 16, 1, 2, 1);
all5=all4.add('American', 5, 4, 3, 1);
all6=all4.add('Australian', 6, 4, 3, 1);
all13=all9.add('Ball', 13, 9, 3, 1);
all11=all9.add('Field', 11, 9, 3, 1);
all15=all9.add('Floor', 15, 9, 3, 1);
all10=all9.add('Ice', 10, 9, 3, 1);
all7=all4.add('Soccer', 7, 4, 3, 1);
all12=all9.add('Underwater', 12, 9, 3, 1);
scroller1.setContent(all0);
all0.setVisible(true);
all0.expand();
added = new Array();
add1=add0.add('Sports', 1, 0, 1, 1);
added[added.length] = new AddedTag( 1, add1 )
add8=add1.add('Baseball', 8, 1, 2, 1);
added[added.length] = new AddedTag( 8, add8 )
add17=add1.add('Basketball', 17, 1, 2, 1);
added[added.length] = new AddedTag( 17, add17 )
scroller2.setContent(add0);
add0.setVisible(true);
add0.expand();
}
function AddedTag( id, node )
{
this.id = id;
this.node = node;
}
function addTagClick( who )
{
if (! all0.rootNode.selected ) return;
var allsel = who || all0.rootNode.selected;
var node = findNode( allsel.parent.tagid );
if (! node )
node = addTagClick( allsel.parent );
var addedTag = node.add( allsel.caption, allsel.tagid,
allsel.parentID, allsel.level, allsel.topLevelID);
added[added.length] = new AddedTag( addedTag.tagid, addedTag
);
return addedTag;
}
function findNode( id )
{
for (var i = 0; i < added.length; i++ )
if ( added[i].id == id )
return added[i].node;
return false;
}
_______________________________________________
Dynapi-Help mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-help