PDA

View Full Version : Trying to load tree with XML data



rosceoman
13 Feb 2012, 1:17 PM
I took one of the working examples and modified it for my needs. Thought this would be a simple change, read the xml from a file and display it in a tree.

the html is:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>XML Tree Example</title>
<link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="../shared/example.css" />

<script type="text/javascript" src="../../bootstrap.js"></script>
<script type="text/javascript" src="xml-4.js"></script>
</head>
<body>
<h1>XML Tree Example</h1>
<p>This example is the same as the <a href="tree.html">tree.html</a> sample, however it
loads from an XML data source.
<p>Note that the js is not minified so it is readable. See <a href="xml-tree.js">tree.js</a>.</p>
<div id="tree-example"></div>
</body>
</html>

the js:
Ext.define('Directory', {
extend: 'Ext.data.Model',
fields: ['FolderID', 'Path', 'Title', 'ShortName', 'UserProfileID', 'DateUpdated', 'DateStart', 'DateStop',
'DomainName', 'SecurityPointID', 'DateCreated', 'GoWord', 'DisplayOrder', 'FolderDepth', 'AuthorizationLevel',
'SystemFolder', 'LockedFlag', 'AppearOnMenu', 'RowNumber']
});

Ext.onReady(function() {

var store = Ext.create('Ext.data.Store', {
model: 'Directory',
proxy: {
type: 'ajax',
url : 'list.xml',
reader: {
type: 'xml',
root : 'root',
record: 'get-active-folder-list',
totalProperty : 'PageInformation > TotalItems',
},
autoLoad: true
}
});

// create the Tree
var tree = Ext.create('Ext.tree.Panel', {
store: store,
hideHeaders: true,
rootVisible: true,
viewConfig: {
plugins: [{
ptype: 'treeviewdragdrop'
}]
},
height: 750,
width: 400,
title: 'Test XML File Read',
renderTo: 'tree-example',
collapsible: true
});
});
And the data from disk:

<?xml version="1.0" encoding="UTF-8"?>
<root>
<get-active-folder-list>
<FolderID>c8fd8b07-bcdc-4b63-8984-b166588d9d65</FolderID>
<Path>/</Path>
<Title>root</Title>
<ShortName>/</ShortName>
<UserProfileID>00000000-0000-0000-0000-000000000000</UserProfileID>
<DateUpdated>2009-06-02T10:08:23.86-04:00</DateUpdated>
<DateStart>2008-06-02T10:08:23.86-04:00</DateStart>
<DateStop>2109-06-03T10:08:23.86-04:00</DateStop>
<DomainName>dev40-pa.mymediabox.com</DomainName>
<SecurityPointID>c8fd8b07-bcdc-4b63-8984-b166588d9d65</SecurityPointID>
<DateCreated>2009-06-02T10:08:23.86-04:00</DateCreated>
<GoWord>root</GoWord>
<DisplayOrder>100</DisplayOrder>
<FolderDepth>0</FolderDepth>
<AuthorizationLevel>2908</AuthorizationLevel>
<SystemFolder>0</SystemFolder>
<LockedFlag>0</LockedFlag>
<AppearOnMenu>1</AppearOnMenu>
<RowNumber>1</RowNumber>
</get-active-folder-list>
<get-active-folder-list>
<FolderID>8a7c8e71-4b1c-466a-a2f4-b871464dc587</FolderID>
<Path>/account</Path>
<Title>Account</Title>
<ShortName>account</ShortName>
<DateUpdated>2007-03-16T11:05:51.627-04:00</DateUpdated>
<ShortDescription>/account</ShortDescription>
<DateStart>2007-03-16T00:00:00-04:00</DateStart>
<DateStop>2107-03-17T00:00:00-04:00</DateStop>
<DomainName>dev40-pa.mymediabox.com</DomainName>
<SecurityPointID>8a7c8e71-4b1c-466a-a2f4-b871464dc587</SecurityPointID>
<DateCreated>2007-03-16T11:05:51.627-04:00</DateCreated>
<GoWord>GO</GoWord>
<DisplayOrder>100</DisplayOrder>
<FolderDepth>0</FolderDepth>
<AuthorizationLevel>2908</AuthorizationLevel>
<SystemFolder>1</SystemFolder>
<LockedFlag>0</LockedFlag>
<AppearOnMenu>1</AppearOnMenu>
<RowNumber>2</RowNumber>
</get-active-folder-list>
<get-active-folder-list>
<FolderID>d1599f0b-f6fb-478a-91f1-17eecb78bb42</FolderID>
<Path>/pa/aaaa/aaaa-mtvnet-000006/</Path>
<Title>AAAA-MTVNET-000006</Title>
<ShortName>aaaa-mtvnet-000006</ShortName>
<DateUpdated>2010-10-25T13:48:56.417-04:00</DateUpdated>
<ShortDescription>AAAA-MTVNET-000006</ShortDescription>
<DateStart>2010-10-25T13:48:56.417-04:00</DateStart>
<DateStop>2110-10-26T13:48:56.417-04:00</DateStop>
<DomainName>dev40-pa.mymediabox.com</DomainName>
<SecurityPointID>d1599f0b-f6fb-478a-91f1-17eecb78bb42</SecurityPointID>
<DateCreated>2010-10-25T13:48:56.417-04:00</DateCreated>
<DisplayOrder>100</DisplayOrder>
<FolderDepth>3</FolderDepth>
<AuthorizationLevel>2908</AuthorizationLevel>
<SystemFolder>0</SystemFolder>
<LockedFlag>0</LockedFlag>
<AppearOnMenu>1</AppearOnMenu>
<RowNumber>52</RowNumber>
</get-active-folder-list>
<get-active-folder-list>
<FolderID>9b5db632-3df2-4ca8-a89f-e48d0eaf41df</FolderID>
<Path>/pa/aaaa/aaaa-mtvnet-000007/</Path>
<Title>AAAA-MTVNET-000007</Title>
<ShortName>aaaa-mtvnet-000007</ShortName>
<DateUpdated>2010-11-08T12:20:58.823-05:00</DateUpdated>
<ShortDescription>AAAA-MTVNET-000007</ShortDescription>
<DateStart>2010-11-08T12:20:58.823-05:00</DateStart>
<DateStop>2110-11-09T12:20:58.823-05:00</DateStop>
<DomainName>dev40-pa.mymediabox.com</DomainName>
<SecurityPointID>9b5db632-3df2-4ca8-a89f-e48d0eaf41df</SecurityPointID>
<DateCreated>2010-11-08T12:20:58.823-05:00</DateCreated>
<DisplayOrder>100</DisplayOrder>
<FolderDepth>3</FolderDepth>
<AuthorizationLevel>2908</AuthorizationLevel>
<SystemFolder>0</SystemFolder>
<LockedFlag>0</LockedFlag>
<AppearOnMenu>1</AppearOnMenu>
<RowNumber>53</RowNumber>
</get-active-folder-list>
</root>

getting an error thrown from ext-all-debug (line 91848).

Any ideas on how to get this to work?

Thanks

Roscoe

mitchellsimoens
13 Feb 2012, 1:29 PM
Please wrap your code in [CODE] tags. It's hard to read that and understand it.

Also, is this for Ext JS 4? Would you like me to move it to the appropriate forum?

rosceoman
13 Feb 2012, 1:36 PM
Yes, this is for 4.0.7 which I downloaded today.

Thanks

Roscoe

rosceoman
13 Feb 2012, 1:41 PM
Can you let me know where it winds up after you move it to the appropriate spot?

Thought I had it here but alas wrong again.

Thanks

Roscoe

mitchellsimoens
13 Feb 2012, 1:46 PM
Moved it to the Ext JS 4 Q&A forum as this is a question about Ext JS 4