Results 1 to 5 of 5

Thread: Problem with TreePanel

  1. #1
    Sencha User
    Join Date
    Dec 2011
    Posts
    59
    Answers
    6

    Default Answered: Problem with TreePanel

    Hello,
    I have a problem with treePanel visualization.
    When I create treepanel for the first time ans initialize it with json data. it looks like this:
    before.JPG
    That is not good.
    But after I reload it (close the Ext.Window and reopen it) once more Tree shows OK
    after.JPG
    Why it does not show right on a first load.
    P.S. JSON - data is same in the first and the second "load"
    P.P.S Using ExtJS 4.0

  2. After hours of debugging I've found a workaround and i hope that developers can explain that.
    The problem is:
    The first child element is filled with all properties:
    Code:
        
    allowDrag true
    allowDrop true
    checked null
    cls ""
    depth 1
    expandable true
    expanded true
    href null
    hrefTarget null
    icon null
    iconCls null
    id 10001
    index 0
    isFirst true
    isLast false
    leaf false
    loaded true
    loading false
    parentId "0"
    qtip null
    qtitle null
    root false
    text "???????? ??????????"
    But all other child elements have no have no properties:
    "expandable","expanded" and property "checkbox" is defined with "undefined".
    A workaround is to modify there properties in append event:
    Listener in TreeStore:
    Code:
                listeners:{
                    append:function(thisNode,newChildNode,index,eOpts){
                        if( !newChildNode.isRoot() ){
                            newChildNode.set("checked",null);
                            newChildNode.set("cls",null);
                            newChildNode.set("expandable",(newChildNode.data.leaf == false));
                            newChildNode.set("expanded",false);
                            console.log(newChildNode);
                        }
                    }
                }

  3. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,449
    Answers
    3997

    Default

    Do you return the checked config for the nodes? If the checked config isn't there, it shouldn't display the check.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  4. #3
    Sencha User
    Join Date
    Dec 2011
    Posts
    59
    Answers
    6

    Default

    Quote Originally Posted by mitchellsimoens View Post
    Do you return the checked config for the nodes? If the checked config isn't there, it shouldn't display the check.
    No I do not use any "checkbox" commands in my config and in JSON data.
    My tree creation code is:
    Code:
    this.treeStore = Ext.create('Ext.data.TreeStore',{
                root: {
                    text:'?????? ???????',
                    id:0,
                    expanded:false
                },
                sorters:[
                    {sorterFn:function(o1,o2){
                        var p1 = o1.raw.sort_id;
                        var p2 = o2.raw.sort_id;
                        if (p1 === p2){
                            return 0
                        }
                        return (p1 < p2) ? -1:1;
                    }}
                ],
                autoload:false,
                proxy:catalog_config                
            });
    ..........
    this.treePanel = Ext.create('Ext.tree.TreePanel',{
                flex: 1,
                title: '?????? ???????',
                height:'100%',
                store: this.treeStore,
            });
    and JSON Response is:
    HTML Code:
    [
    {"text": "\u041b\u0435\u0433\u043a\u043e\u0432\u044b\u0435 \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u0438", "sort_id": 1, "leaf": false, "id": 10001}, 
    {"text": "\u0422\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u043d\u044b\u0435 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430 \u043a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f", "sort_id": 965, "leaf": false, "id": 20002}, 
    {"text": "\u0414\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u044c", "sort_id": 1720, "leaf": false, "id": 30003}, 
    {"text": "\u041e\u0441\u044c", "sort_id": 1948, "leaf": false, "id": 40004}]

  5. #4
    Sencha User
    Join Date
    Dec 2011
    Posts
    59
    Answers
    6

    Default

    Another problem with treePanel.
    When i do reconfigure and store.load it deletes the first child element or the root and raises an exception:
    Code:
    uncaught exception: You are using a ServerProxy but have not supplied it with a url.
    http://localhost/site/extjs/ext-debug.js
    Line 12151
    I'm reloading using this code:
    Code:
                    this.treeStore.proxy.extraParams = {list:'tree',typeid:record.data.code};
                    this.treeStore.proxy.setModel('asv.model.tree');        
                    this.treePanel.store.load();
                    this.treePanel.reconfigure();
    But i'm sure that I've specified url in a proxy.
    Besides that, when i reload it 4 times (everty time i reload, the treepanel keep deleting root children one by one) it reloads all tree children normally

  6. #5
    Sencha User
    Join Date
    Dec 2011
    Posts
    59
    Answers
    6

    Default

    After hours of debugging I've found a workaround and i hope that developers can explain that.
    The problem is:
    The first child element is filled with all properties:
    Code:
        
    allowDrag true
    allowDrop true
    checked null
    cls ""
    depth 1
    expandable true
    expanded true
    href null
    hrefTarget null
    icon null
    iconCls null
    id 10001
    index 0
    isFirst true
    isLast false
    leaf false
    loaded true
    loading false
    parentId "0"
    qtip null
    qtitle null
    root false
    text "???????? ??????????"
    But all other child elements have no have no properties:
    "expandable","expanded" and property "checkbox" is defined with "undefined".
    A workaround is to modify there properties in append event:
    Listener in TreeStore:
    Code:
                listeners:{
                    append:function(thisNode,newChildNode,index,eOpts){
                        if( !newChildNode.isRoot() ){
                            newChildNode.set("checked",null);
                            newChildNode.set("cls",null);
                            newChildNode.set("expandable",(newChildNode.data.leaf == false));
                            newChildNode.set("expanded",false);
                            console.log(newChildNode);
                        }
                    }
                }

Posting Permissions

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