PDA

View Full Version : Treepanel not loading items from xml store



AyKarsi
23 Jul 2012, 4:20 AM
I want my treepanel to load children when clicking on a node. I can see that the request is being sent and valid Xml is being returned back, but nothing happens in the tree/node.Any ideas?

My Model:

Ext.define('Macros.model.foldertreeModel', {
extend: 'Ext.data.Model',
fields: [
{ name: 'id', type: 'string', mapping: 'id' },
{ name: 'text', type: 'string', mapping: 'path' }
]
});

My Store:

Ext.define('Macros.store.foldertreeStore', {
extend: 'Ext.data.TreeStore',
model: 'Macros.model.foldertreeModel',
autoLoad:true,
rootVisible: true,
defaultRootId: "0",
proxy: new Ext.data.proxy.Ajax({
url:proxyUrl+'?entity=foldertree&id=0',
method:'get',
reader: {
type: 'xml',
rootProperty : 'results',
record: 'record'
}
}),
root: {
expanded: true,
text: "Ordner",
id: "0"
},
loadChildren: function(parentId){
this.proxy.url = proxyUrl+'?entity=foldertree&id='+parentId;
this.load();
}
});


My View:

Ext.define('Macros.view.folder.tree' ,{
extend: 'Ext.tree.Panel',
alias : 'widget.foldertree',
title : 'All Users',
store: 'foldertreeStore',
initComponent: function() {
this.on("itemclick", this.itemclick);
this.callParent(arguments);
},

itemclick:function(view, record, item, index, event){
var id = record.data.id;
this.store.loadChildren(id);
console.log("expand "+id);
}
});


My Xml-Response:

<?xml version="1.0" encoding="UTF-8"?>
<results>
<record>
<id>1</id>
<path>News</path>
</record>
<record>
<id>2</id>
<path>Projekte</path>
</record>
<record>
<id>3</id>
<path>Themenordner</path>
</record>
<record>
<id>7</id>
<path>Fonds</path>
</record>
<record>
<id>8</id>
<path>TEST</path>
</record>
<record>
<id>9</id>
<path>Vorlagen</path>
</record>
</results>