Loading ...
Sorry, an error occurred while loading the content.

Re: getEl() Error using TreeView

Expand Messages
  • softwareforhumanity
    Satyam, Thank you for you input. I have moved the control/JavaScript to a single page and it s working. Thanks, Robert
    Message 1 of 5 , Apr 29, 2009
    • 0 Attachment
      Satyam,

      Thank you for you input. I have moved the control/JavaScript to a single page and it's working.

      Thanks,

      Robert

      --- In ydn-javascript@yahoogroups.com, Satyam <satyam@...> wrote:
      >
      > Different frame you say? All bets are off then. Method getEl ends up
      > doing a document.getElementById which won't find an element in a
      > separate frame, which is another document in a separate branch. Even if
      > you were able to fix this, many other issues would pop up, I would
      > recommend you avoid frames. Check the Container family of components and
      > the Layout component to see if either suits your needs. Frames will
      > only give you headaches.
      >
      > Satyam
      >
      >
      > softwareforhumanity escribió:
      > > Folks,
      > >
      > > 1) lbox.value is the data I have listed in 1 below. It seems to populat the tree fine.
      > >
      > > 2) tvElements is the actual DOM "Div" element I'm pushing the tree into. The tree might be in a different frame then the running Javascript.
      > >
      > > It seems like the problem is related to the "el" caching. For whatever reason "el" seems to be set to null for the Nodes in the tree.
      > >
      > > I wonder how the "el" data gets setup when the tree is created.
      > >
      > > Regards,
      > >
      > > Robert
      > >
      > > --- In ydn-javascript@yahoogroups.com, "Satyam" <satyam@> wrote:
      > >
      > >> --- In ydn-javascript@yahoogroups.com, "softwareforhumanity" <rjack2@> wrote:
      > >>
      > >>> Folks,
      > >>>
      > >>> I added a custom property, row_number, to my treeview data. Now I cannot open the tree.
      > >>>
      > >>> 1) Here is the Data I'm using to populate the tree.
      > >>>
      > >>> [ {type:'text', label:'Product A', row_number:'0' , children: [ {type:'text',
      > >>> label:'1', row_number:'0' , children: [ {type:'text', label:'1.1',
      > >>> row_number:'0'} ]} , {type:'text', label:'2', row_number:'1' , children: [
      > >>> {type:'text', label:'1.1', row_number:'1'} ]} ]} , {type:'text', label:'Product C
      > >>> ', row_number:'2' , children: [ {type:'text', label:'3',
      > >>> row_number:'2'} , {type:'text', label:'4', row_number:'3'} ]} , {type:'text',
      > >>> label:'Product B CICS Service', row_number:'4' , children: [ {type:'text',
      > >>> label:'5', row_number:'4'} ]} , {type:'text', label:'Product B CICS Services',
      > >>> row_number:'5' , children: [ {type:'text', label:'6', row_number:'5' , children:
      > >>> [ {type:'text', label:'6.6', row_number:'5'} ]} ]} , {type:'text', label:'Product G',
      > >>> row_number:'6' , children: [ {type:'text', label:'7', row_number:'6'}
      > >>> , {type:'text', label:'8', row_number:'7'} ]} , {type:'text', label:'Product H
      > >>> for Product B', row_number:'8' , children: [ {type:'text', label:'9',
      > >>> row_number:'8'} , {type:'text', label:'10', row_number:'9' , children: [
      > >>> {type:'text', label:'10.10', row_number:'9'} ]} ]} , {type:'text', label:'Product D',
      > >>> row_number:'10' , children: [ {type:'text', label:'11',
      > >>> row_number:'10'} , {type:'text', label:'12', row_number:'11'} ]} ]
      > >>>
      > >>> 2) Here is the code..
      > >>>
      > >>> YAHOO.namespace("yuibook.tree");
      > >>>
      > >>> // Get Element
      > >>> var tvElement = eval("AppWindow.ListBox1");
      > >>>
      > >>> // create tree
      > >>> var tree = new YAHOO.widget.TreeView(tvElement, lbox.value);
      > >>>
      > >>> tree.draw();
      > >>>
      > >>> tree.subscribe("labelClick", function(node){
      > >>>
      > >>> alert("clicked tree");
      > >>>
      > >>> });
      > >>>
      > >>> I see the alert and then I get the error:
      > >>>
      > >>> 3) Error is: "Object Required. Looks like this.getEl() is null.
      > >>>
      > >>> Do I have to define El() since I added a custom property.
      > >>>
      > >>> Here is the code that id complaining:
      > >>>
      > >>> tree..min.js
      > >>>
      > >>> Line 1120
      > >>>
      > >>> B.getElementsBy(function(G){
      > >>> return /ygtv(([tl][pmn]h?)|(content))/.test(G.className);
      > >>> }, "td", this.getEl().firstChild, function(H)
      > >>>
      > >>> Regards,
      > >>>
      > >>> Robert
      > >>>
      > >>>
      > >> I am not sure what lbox.value might be, but I would assume it is a string value from an input box. The second argument for the TreeView constructor, if there is any, should be an object or an array. If it is a string, it can only be text which will be assumed to be the label text for a single node, the whole of that text crammed into a single node. If you are reading a string from an input box, you should use the JSON utility to parse it into an actual JavaScript array of objects.
      > >>
      > >> Also, avoid using deprecated events such as labelClick which does not even show in the API docs unless you explicitly ask for it.
      > >>
      > >> I am also not sure why would you use an eval to evaluate that string, does that evaluate to a DOM element or the ID of an existing DOM element? Does variable tvElement contain either?
      > >>
      > >> BTW, reporting errors on minified code is mostly useless. The compression process makes most of the code unrecognizable. Those variables called B, G and H are short names generated by the compressor replacing the more verbose and meaningful original names. The compressor also eliminates most of the line breaks so neither the source code nor the line numbers on minified code have any relation to the original readable source code.
      > >>
      > >>
      > >
      > >
      > >
      > >
      > > ------------------------------------
      > >
      > > Yahoo! Groups Links
      > >
      > >
      > >
      > > ------------------------------------------------------------------------
      > >
      > >
      > > No virus found in this incoming message.
      > > Checked by AVG - www.avg.com
      > > Version: 8.5.287 / Virus Database: 270.12.4/2082 - Release Date: 04/27/09 06:19:00
      > >
      > >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.