ENART.POLALA.COM
welcome to my space
X
Coffee | Sexuality | Medicine | Elderly Care | Soccer | Insurance | Small Business | Exotic Locations | Related articles

[NOT BUG] TreeNode isLeaf broken

Published by: jack 2010-03-19
  • hello,

    i find TreeNode.isLeaf not work correct:

    my tree:

    var myTree = function() {
    return {
    init : function(id) {
    // yui-ext tree
    var Tree = Ext.tree;

    // tree
    this.tree = new Tree.TreePanel('tree_' + id, {
    animate:true
    , loader: new Tree.TreeLoader({
    dataUrl:'source.php'
    , baseParams: {root_id: id}
    })
    , enableDD:true
    , containerScroll: true
    });

    // set the root node
    this.root = new Tree.AsyncTreeNode({
    text: 'Ext JS'
    , draggable:false
    , id:'source'
    });
    this.tree.setRootNode(this.root);

    // render the tree
    this.tree.render();

    this.tree.on({
    contextmenu: {scope:this, fn:this.onContextMenu}
    , dblclick: {scope:this, fn:this.openNode}
    });

    this.root.expand();
    }

    , onContextMenu : function(node, e) {
    // no browser context menu
    e.stopEvent();
    e.preventDefault();

    console.info("root ::" + node.root);
    console.info("isRoot ::" + node.isRoot);
    // console.info("isRoot() ::" + node.isRoot());
    console.info("node.leaf ::" + node.leaf);
    console.info("node.isLeaf ::" + node.isLeaf);
    console.info("node.isLeaf() ::" + node.isLeaf());

    if(node.isRoot)
    {
    // save current node to context menu
    this.rootContextMenu.node = node;

    // show menu under node
    this.rootContextMenu.show(node.ui.getAnchor());
    }
    // not working
    // else if(node.isLeaf)
    else if(node.leaf)
    {
    // save current node to context menu
    this.leafContextMenu.node = node;

    // show menu under node
    this.leafContextMenu.show(node.ui.getAnchor());
    }
    The leaf node has node.leaf = true but node.isLeaf return false ;(

    output (root):
    root ::undefined
    isRoot ::true
    node.leaf ::undefined
    node.isLeaf ::function () { return this.leaf === true; }
    node.isLeaf() ::false

    output (leaf):
    oot ::undefined
    isRoot ::undefined
    node.leaf ::true
    node.isLeaf ::function () { return this.leaf === true; }
    node.isLeaf() ::false

    output (not leaf):
    root ::undefined
    isRoot ::undefined
    node.leaf ::undefined
    node.isLeaf ::function () { return this.leaf === true; }
    node.isLeaf() ::false


  • And what's wrong? If value of node.leaf equals undefined then true === node.leaf equals false.


  • in the function onContextMenu i get always true (root, not leaf node and on a leaf node):


    , onContextMenu : function(node, e) {
    alert((node.isLeaf) ? 'true':'false');
    ...


    Sure, because isLeaf is function. Try:


    , onContextMenu : function(node, e) {
    alert((node.isLeaf()) ? 'true':'false');


  • Yes, because node.leaf is undefined. The code behaves exactly as it should. Do you know what === operator does? It compares value and type and only if both are equal it evaluates as true.


  • sorry i found my mistake the json return was a string not a boolean ;(
    but why have ext a different handling for

    is***

    isRoot is a var and isLeaf is a function???


  • Those are design decisions of Jack.

    This is not a bug. Closing thread...


  • in the function onContextMenu i get always true (root, not leaf node and on a leaf node):


    , onContextMenu : function(node, e) {
    alert((node.isLeaf) ? 'true':'false');
    ...


  • ok but

    alert(node.isLeaf());

    return always false ;( see debug info at the first post


  • BTW, have you read this: http://extjs.com/forum/showthread.php?t=8887





  • Allergies.. no relief?!?
    Religion in the workplace?
  • poor old joe lieberman refuses to give up his job we just told him to leave what do we do
  • how old is joe jonas and nike jonas
  • how old was the oldest player ever to play a pro sport
  • how can we elect this joe the plumber president
  • i think the ny yankee thing with joe torre is getting old
  • how old were max schmeling and joe louis when they fought both fights
  • how to throw a punch with maximum force
  • which guy would you rather have to build a team around a 23 year old joe montana or a 23 year old jim brown
  • who 039 s on the undercard
  • old mand and the sea and joe damijoo
  • how old is selena gomez demi lovato and joe jonas
  • who thinks that joe and his guitar is a little too old
  • can my 4 yr old sit on my lap at joe lewis arena or do i have to buy him a ticket
  • old joe
  • old fat joe obese or present fat joe
  •  
  • is there any way to strengthen your resistance to knockout punches
  • how old is joe jonas please help true
  • is arthur abraham a serious threat to pavliks middleweight titles i think he definately is
  • in boxing when the fight is at a catch weight does that mean no title will be fought for
  • hi could you help me figure out this math question
  • old joe the poacher
  • in damn yankees if old joe is white do you think joe hardy could be black cant mr applegate do anything
  • i am looking to sell some baseball figurines that are 30yrs or so old babe ruth joe d and one other where
  • where did the old term of calling a cup of coffee a cup of joe come from
  • the vp debate lasted 90 mins how did old joe get away with a lie every 5 mins
  • where does joe old bones brown rank in your all time lightweight list
  • how do i explain old cutting scars
  • for next season should joe gibbs ditch suanders 039 finesse plays and go back to his own
  • why do we let just any old joe in from canada but we don 039 t want any mexicans crossing our border
  • Search:  
    #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about [NOT BUG] TreeNode isLeaf broken , Please add it free.

    About us -Site map -Advertisement -Jion us -Contact usExchange linksSponsor us
    Copyright© 2008 enart.polala.com All Rights Reserved
    Site made&Support support@enart.polala.com    E-mail: web@enart.polala.com