Q:

ExtJS problem inserting new child in a treepanel

I'm trying to populate a tree on demand. I'm capturing the doubleclick event and this is the code in my controller:
itemdblclick: function(item, record, eOpts) {
       console.log(item, record, eOpts);
       var store = Ext.getStore('mystoreid');
       var node = store.getRootNode().findChild('idelement', record.data.idelement, true);

       node.insertChild(
           {
               idelement: '100',
               descript: 'AAAAA',
               active: true,
               idparent: record.data.idelement,
               name: '01010101010',
               text: 'Show yourself, please!',
               leaf: true,
               loaded: true,
               children: []
           }
       );

       node.expand();
    }

This code shows me this error:
Uncaught TypeError: Cannot read property 'isModel' of undefined
    at constructor.createNode (ext-all-debug.js:108050)
    at constructor.appendChild (ext-all-debug.js:108224)
    at constructor.insertChild (ext-all-debug.js:108790)
    at constructor.loadRecords (SelectorNiveles.js:79)
    at constructor.fire (ext-all-debug.js:20731)
    at constructor.dispatch (ext-all-debug.js:57952)
    at constructor.callParent (ext-all-debug.js:12493)
    at constructor.dispatch (ext-all-debug.js:58196)
    at constructor.prototype.doFireEvent (ext-all-debug.js:58109)
    at constructor.fireEventArgs (ext-all-debug.js:21553)

I've been googleing for a solution, unsuccessfully. I'm using Firefox and Chromium and Extjs 6.0.2, What am I doing wrong?

A:

Don't know if this is the source of your error, but according to the docs you need to pass an index before the node you want to add:
node.insertChild(
           0,{
               idelement: '100',
               descript: 'AAAAA',
               active: true,
               idparent: record.data.idelement,
               name: '01010101010',
               text: 'Show yourself, please!',
               leaf: true,
               loaded: true,
               children: []
           }
       );

