PDA

View Full Version : Tree appendChild & records[i] is undefined



slsb02
13 Jan 2012, 5:45 AM
Hello,

sorry my English is bad.
I have a problem...

I create a Tree and add children dynamic.
I open the Folder "User" in Tree an see the dynamic data, no problem. Then close the Folder "User" an reopen the Folder all data are double an Firbug displayed the error: "records[i] is undefined". I have no Idea... Please can you help me?

See my code:


var store_test_list = Ext.create('Ext.data.TreeStore', {
id: 'test',
extend: 'Ext.data.Model',
autoLoad: false,
fields: ['coworker_id', 'text', 'iconCls', 'leaf'],
proxy: {
actionMethods: { create: 'POST', read: 'POST', update: 'POST', destroy: 'POST' },
extraParams: { task: "coworker_list"},
type: 'ajax',
url: CoworkerHelperFile,
reader: {
type: 'json',
root: 'coworker_list',
},
},
listeners: {
append: function( thisNode, newChildNode, index, eOpts ) {
if( !newChildNode.isRoot() ) {
newChildNode.set('leaf', true);
newChildNode.set('text', newChildNode.get('text'));
newChildNode.set('iconCls', newChildNode.get('iconCls'));
newChildNode.set('id', 'config_company_type_list_add');
newChildNode.set('coworker_id', newChildNode.get('coworker_id'));
}
}
},
});store_test_list.setRootNode({
id: 'tester',
text: 'Users',
leaf: false,
expanded: false
});

var system_configure_tree = Ext.create('Ext.tree.Panel', {
id:'system-configure-tree',
title: '<b>Settings</b>',
rootVisible:false,
lines:true,
autoScroll:true,
//store: store_system_configuration,
//store: store_test_lists,
viewConfig: {
listeners: {
itemdblclick: function(dv, record, item, index, e) {
if(record.data.id != ''){
wsb_wawi_get_config_edit_window(record.data.id);
}
},
itemcontextmenu: function(dv, record, item, index, e) {
if(record.data.id != ''){
this.getSelectionModel().select(index); //Markiere ausgewählte Zeile
ShowConfig_Languages_RightClickMenu(e, record.data.id);
}
//showcoworkerListGridMenu(dv, record, item, index, e);
}
}
}
});

var node = system_configure_tree.getRootNode();
node.appendChild(store_test_list.getRootNode());


and Screenshoot:
1. first open... perfect
30690

2. folder can close

3. reeopen
30691

close
30692

reopen
30693

after second open you can't close...

Thank you!

mitchellsimoens
13 Jan 2012, 7:52 AM
Do you want it to keep adding child nodes when you expand?

slsb02
13 Jan 2012, 8:44 AM
Hello,
it would be beautiful, if the data are loaded, if one opens the folder. Because I must be able to update the list also.

slsb02
14 Jan 2012, 10:56 AM
no an idea?