PDA

View Full Version : Tree Panel and Folders



cnhanna01
7 Dec 2011, 7:55 AM
I've been working with the 'Ext.tree.Panel' and I am unable to get parent folders to show up. I am using the tree 'Ext.data.TreeStore' with an ajax call that returns an xml file.Here is example code:

TreeStore:


Ext.onReady(function () {
var store = Ext.create('Ext.data.TreeStore', {
proxy: {
type: 'ajax',
url: 'document',
extraParams: {
action: "fetchFiles",
acct: "31"
},
reader: {
type : 'xml',
root : 'src',
record: 'document'
}
},
root: {
text: 'My Documents',
expanded: true,
},
folderSort: true,
sorters: [{
property: 'title',
direction: 'ASC'
}]
});


XML:


<?xml version="1.0" encoding="UTF-8"?>
<src>
<folder>
<cls>folder</cls>
<leaf/>
<text>Past Survey Results</text>
<document>
<id>3</id>
<leaf>1</leaf>
<cls>file</cls>
<text>ABC - 2011 Survey Results.pdf</text>
<href>
some url
</href>



</document>


<document>
<id>4</id>
<leaf>1</leaf>
<cls>file</cls>
<text>2011 Test.pdf</text>
<href>
someurl
</href>



</document>



</folder>


<folder>
<id>12</id>
<leaf/>
<cls>folder</cls>
<text>Past Partnership Reviews</text>
<document>
<id>5</id>
<leaf>1</leaf>
<cls>file</cls>
<text>Another test.pdf</text>
<href>
some url
</href>



</document>



</folder>



</src>

tvanzoelen
7 Dec 2011, 8:22 AM
parent and childnodes must have the same root as defined in the root property.

You defined folder, document. I don't think the reader will understand that

try


src
document
document
src
document
document
document

See
http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.TreeStore
about reading nested data