1. #1
    Sencha Premium Member
    Join Date
    Oct 2011
    Posts
    55
    Answers
    4
    Vote Rating
    0
    dwb is on a distinguished road

      0  

    Default Unanswered: Create a new TreePanel Node and Select it.

    Unanswered: Create a new TreePanel Node and Select it.


    Hello,

    I've got a tree panel and I'm adding leaf nodes to it from the panel's controller.

    Controller Code:

    addEventRule: function(){
    var content = Ext.getCmp('BillingPlanTreeCtn'); //wrapper
    var win = Ext.getCmp('billplanwin'); //add event window
    var createContainer = Ext.create('Nile.view.layout.BillingPlanTree'); //new instance of treepanel
    var bpTree = Ext.getCmp('BillingPlanTree'); //get treepanel
    var infoMsg = Ext.getCmp('infoMsg'); //default user message
    var bpCombox = Ext.getCmp('BillPlanCombox'); //event rule combox
    var taskTxt = bpCombox.getValue(); //event-type txt

    //if content is info message, remove this, replace with new treepanel
    if(!infoMsg){
    bpTree.getRootNode().appendChild({
    task: taskTxt,
    id: 'leaf-'+ i,
    activeItem: true,
    iconCls: 'iconEventRuleSet',
    leaf: true,
    });
    win.destroy(); //bye win
    }
    //else kill info msg, add blank treepanel & kill win
    else{
    content.removeAll(true);
    //new event rule node
    bpTree.getRootNode().appendChild({
    task: taskTxt,
    id: 'leaf-'+ i,
    iconCls: 'iconEventRuleSet',
    leaf: true
    });
    content.add(createContainer);
    createContainer.doLayout();
    createContainer.show();
    win.destroy();
    };
    bpTree.getView().select(0);
    //works when 1st new node is added.
    //additional nodes cause error:
    Cannot call method 'getAt' of undefined
    }


    Anyone know how to make the last leaf created to be selected? With the arrangement above, I get the first node to be selected, but, all following node additions result in an error: Cannot call method 'getAt' of undefined

  2. #2
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    346
    Vote Rating
    109
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      0  

    Default


    I have simulated your case by creating a tree, appending child nodes to it then selecting the last node and everything worked well without error. I am not sure what causes the problem with your code, however, let try by fixing your code as follow (in red color):
    Code:
    ...
    var node;
    if(!infoMsg){
        node = bpTree.getRootNode().appendChild({
            task: taskTxt,
            id: 'leaf-'+ i,
            activeItem: true,
            iconCls: 'iconEventRuleSet',
            leaf: true,
        });
        win.destroy(); //bye win
    }
    //else kill info msg, add blank treepanel & kill win
    else{
        content.removeAll(true);
        //new event rule node
        node = bpTree.getRootNode().appendChild({
            task: taskTxt,
            id: 'leaf-'+ i,
            iconCls: 'iconEventRuleSet',
            leaf: true
        });
        content.add(createContainer);
        createContainer.doLayout();
        createContainer.show();
        win.destroy();
    };
    bpTree.getView().select(node);
    ...

  3. #3
    Sencha Premium Member
    Join Date
    Oct 2011
    Posts
    55
    Answers
    4
    Vote Rating
    0
    dwb is on a distinguished road

      0  

    Default Select Tree Node after creation

    Select Tree Node after creation


    Hi vietits,

    Thanks for the valent effort. I've introduced the changes your've shown me and now I'm receiving a different error:
    Cannot read property 'length' of undefined. Looks like Ext is having issues reading the length of the node array ... maybe? Or, has our Node var returned "undefined"? Or both? I'm baffled, but, I'm getting used to it - seems to be par for the Ext course.

    Well, I'm checking that I've put in the correct "Required" configuration etc. and anything else I can think of.

    Thanks again for this nugget of knowledge - I really appreciate you efforts.

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar