View Full Version : Javascript Trees

04-19-2009, 12:04 AM
Hi all, I have the following code which I got from the Firefox MDC website:

The beginning looks something like this:

var treeView = {
childData : {
Something: ["Silver", "Gold", "Lead"],
Else: ["Mercury"],
Gases: ["Helium", "Nitrogen"]

visibleData : [
["Something", true, false],
["Else", true, false],
["Gases", true, false]

treebox: null,
selection: null,

get rowCount() { return this.visibleData.length; },
setTree: function(treeBox) { this.treeBox = treeBox; },
getCellText: function(idx, column) { return this.visibleData[idx][0]; },
isContainer: function(idx) { return this.visibleData[idx][1]; },
isContainerOpen: function(idx) { return this.visibleData[idx][2]; },
isContainerEmpty: function(idx) { return false; },

I wish to create my own 3D array which will replace visibleData.

Something like this:

var visibleData = new Array(3);
for (var i = 0; i < 3; i++) {
visibleData[i] = ["TEst", true, false];

where can I put the above code? I tried putting it outside the treeView but it doesnt work, and I do not know how to insert it in the treeview.



04-19-2009, 01:11 AM
visibleData :{
for (var i = 0; i < 3; i++) {
visibleData[i] = ["TEst", true, false];

I'm not sure, but I think this will return an array you want

04-19-2009, 02:13 AM
thanks TinyScript for such a promt reply as usual!

It seems that doesnt work either!
the link I am getting the script from is

04-19-2009, 02:24 AM
Yeah, I didn't test it, but it looks that would loop and make the array. maybe you have to wrap it in []

04-19-2009, 11:32 AM
mmmm, yeah it seems it should.It's a bit of a pain

Thanks anyways though!

04-20-2009, 05:38 PM
anyone can help?

I am still stuck on this issue!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum