1. #1
    Sencha User
    Join Date
    Nov 2012
    Posts
    6
    Vote Rating
    1
    richiejaeger is on a distinguished road

      0  

    Default Unanswered: Tree has to be collapsed to appendChild?!

    Unanswered: Tree has to be collapsed to appendChild?!


    Hey,

    i got the following function to add new childs to an existing node:

    Code:
    saveModule: function(button) {
            var win = button.up('window'),
                form = win.down('form').getForm(),
                tree = this.getController('Format').getFormatSelection(),
                store = tree.getStore(),
                parent = tree.getSelectionModel().getSelection()[0],
                node = store.getNodeById(parent.getId());
    
    
            if (form.isValid()) {
                //tree.collapseAll();
                
                var record = node.createNode({ name: form.findField('module_id').getStore().findRecord('id', form.getFieldValues().module_id).get('name'), leaf: true, parentId: parent.getId() });
                node.appendChild(record);
                record.save({
                    success: function() {
                        win.close();
                        store.reload();
                    }
                });
            }
        }
    The node gets created via my proxy. I can also find the new record in my Database. But i get an error, if i add the childnode to an expanded node:

    Uncaught TypeError: Cannot read property 'internalId' of undefined
    If i add an record to an collapsed node, i dont get any error...

    Is this problem known or am i just doing something wrong?!

    Regards
    Richie

  2. #2
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    4,913
    Answers
    371
    Vote Rating
    179
    slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold

      0  

    Default


    This works for me in 4.2:
    You want to see if it fails when you try with it?

    Code:
    var store = Ext.create('Ext.data.TreeStore', {
        root: {
            expanded: true,
            children: [
                { text: "detention", leaf: true },
                { text: "homework", expanded: true, children: [
                    { text: "book report", leaf: true },
                    { text: "algebra", leaf: true}
                ] },
                { text: "buy lottery tickets", leaf: true }
            ]
        }
    });
    
    
    Ext.create('Ext.tree.Panel', {
        title: 'Simple Tree',
        width: 200,
        height: 220,
        store: store,
        rootVisible: false,
        renderTo: Ext.getBody()
        , tbar: [{
            text: 'Add node'
            , handler: function (btn) {
                var dest = btn.up('treepanel').getRootNode().getChildAt(1);
                dest.appendChild({text: 'added', leaf: true});
            }
        }]
    });

Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi