Hybrid View

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Ext JS Premium Member
    Join Date
    May 2008
    Posts
    57
    Vote Rating
    0
    xsuniwov is on a distinguished road

      0  

    Default [FIXED-278][2.x,3.x] AsyncTreeNode's loader is overridden by the one from treePanel

    [FIXED-278][2.x,3.x] AsyncTreeNode's loader is overridden by the one from treePanel


    We found Ext 2.2 starts to support literal config for TreeNode, AsyncTreeNode and TreeLoader. That helps us a lot and thank you!

    Here is still a problem on AsyncTreeNode's TreeLoader. For example:

    var tree = new Ext.tree.TreePanel({
    xtype: 'treepanel',
    el:'tree',
    animate:true,
    autoScroll:true,
    containerScroll:true,
    autoHeight: true,
    loader: {dataUrl: "http://server/webapps/treePanel.jsp"},
    root:
    {
    text: 'root2',
    draggable:false, // disable root node dragging
    loader: {dataUrl: "http://server/webapps/treeNode.jsp"},
    id:'root',
    expanded: true
    }
    });
    tree.render();
    });

    "http://server/webapps/treeNode.jsp" never gets called. The same thing applies to all the children nodes. Even if they have different loader configured, Ext still uses TreePanel's loader to create the next level nodes.

    Debug through the source codes, I found two suspicious places:

    1. In TreeLoader.js
    ...
    createNode : function(attr){
    // apply baseAttrs, nice idea Corey!
    if(this.baseAttrs){
    Ext.applyIf(attr, this.baseAttrs);
    }
    if(this.applyLoader !== false){
    attr.loader = this;

    }
    ...

    It seems like it doesn't honor node's own loader. what is "applyLoader" used for?

    2. In AsyncTreeNode.js
    Ext.tree.AsyncTreeNode = function(config){
    this.loaded = config && config.loaded === true;
    this.loading = false;
    Ext.tree.AsyncTreeNode.superclass.constructor.apply(this, arguments);
    /**
    * @event beforeload
    * Fires before this node is loaded, return false to cancel
    * @param {Node} this This node
    */
    this.addEvents('beforeload', 'load');
    /**
    * @event load
    * Fires when this node is loaded
    * @param {Node} this This node
    */
    /**
    * The loader used by this node (defaults to using the tree's defined loader)
    * @type TreeLoader
    * @property loader
    */
    };

    It mentions the loader, but doesn't initialize it from "config", why?

    I made two changes at these places and it seems make it work:
    1.
    ...
    if(this.applyLoader !== false){
    attr.loader = attr.loader || this;
    }
    ...

    2.
    ...
    var l = config.loader;
    if(!l){
    l = new Ext.tree.TreeLoader({
    dataUrl: this.dataUrl
    });
    }else if(typeof l == 'object' && !l.load){
    l = new Ext.tree.TreeLoader(l);
    }
    this.loader = l;
    ...

    Not sure if these are right fixes though.

  2. #2
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,509
    Vote Rating
    374
    jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future

      0  

    Default


    Do you think this is a bug? I can move this thread to Bugs forum then.
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid Search Plugin, ExtJS 5 Complex Data Binding using MVVM


  3. #3
    Ext JS Premium Member
    Join Date
    May 2008
    Posts
    57
    Vote Rating
    0
    xsuniwov is on a distinguished road

      0  

    Default


    Can you confirm this is a bug or we just use it wrong? If yes, sure, you can move it to the right place.

  4. #4
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,509
    Vote Rating
    374
    jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future

      0  

    Default


    I haven't tested it personally but if node's loader is not called but the tree's one, as you say, it looks like bug. If nowhere else then in docs.

    Moving the thread to bugs.
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid Search Plugin, ExtJS 5 Complex Data Binding using MVVM


  5. #5
    Ext User
    Join Date
    Feb 2008
    Posts
    3
    Vote Rating
    0
    bosok is on a distinguished road

      0  

    Default


    I think this is a bug, I am experiencing the same phenomenon. I cannot define different Treeloaders for different nodes in a tree...

  6. #6
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,648
    Vote Rating
    583
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Agreed, the tree loader should only inherit if the node hasn't specified a loader.

    However, if there is no loader defined on a node and the parent node has a loader, which loader should the node use? It would be most logical for it to be the loader of the parent.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  7. #7
    Ext JS Premium Member
    Join Date
    May 2008
    Posts
    57
    Vote Rating
    0
    xsuniwov is on a distinguished road

      0  

    Default


    I think it is more logical to use parent's loader than to use treePanel's one.

  8. #8
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,496
    Vote Rating
    44
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    I agree. That way you can have branches loaded from different loaders which offers flexibility. I seem to remembert posting a Feature Request about this.

  9. #9