Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Mar 2009
    Posts
    45
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Javascript Trees

    Hi all, I have the following code which I got from the Firefox MDC website:

    The beginning looks something like this:
    Code:
     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:

    Code:
    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.

    Thanks

    Chris

  • #2
    Regular Coder
    Join Date
    Mar 2009
    Location
    Portland Oregon
    Posts
    690
    Thanks
    44
    Thanked 63 Times in 62 Posts
    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

  • #3
    New Coder
    Join Date
    Mar 2009
    Posts
    45
    Thanks
    3
    Thanked 0 Times in 0 Posts
    thanks TinyScript for such a promt reply as usual!

    It seems that doesnt work either!
    the link I am getting the script from is
    https://developer.mozilla.org/en/XUL...e_View_Details

  • #4
    Regular Coder
    Join Date
    Mar 2009
    Location
    Portland Oregon
    Posts
    690
    Thanks
    44
    Thanked 63 Times in 62 Posts
    Yeah, I didn't test it, but it looks that would loop and make the array. maybe you have to wrap it in []

  • #5
    New Coder
    Join Date
    Mar 2009
    Posts
    45
    Thanks
    3
    Thanked 0 Times in 0 Posts
    mmmm, yeah it seems it should.It's a bit of a pain

    Thanks anyways though!

  • #6
    New Coder
    Join Date
    Mar 2009
    Posts
    45
    Thanks
    3
    Thanked 0 Times in 0 Posts
    anyone can help?

    I am still stuck on this issue!


  •  

    Posting Permissions

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