PDA

View Full Version : Tree Not Loading Nodes On Demand



adavis2
15 Apr 2014, 8:02 AM
I'm trying to setup a tree panel to load child nodes on demand (when a non-leaf node is expanded). I'm using Ext JS 4.2.2-commercial. The children of the root node are loaded correctly, but the TreeStore.load method is not called when those nodes are expanded. Here's what the TreePanel config looks like:

{
xtype: 'treepanel',
id: 'labTree',
store: 'LabTreeStore',
singleExpand: true,
displayField: 'Name'
}
TreeStore config:

Ext.define('LabData.store.LabTreeStore', {
extend: 'Ext.data.TreeStore',
storeId: 'LabTreeStore',
autoLoad: false,
model: 'LabData.model.LabTreeNode',
nodeParam: 'Oid',
root: {
expanded: false,
Name: 'Laboratories',
Oid: null
},
proxy: {
type: 'WindchillProxy',
api: {
read: 'servlet/IE/tasks/ext/TACOM/labdata/readChildren.xml'
},
reader: {
type: 'WindchillXml',
group: 'Children'
}
}
});
WindchillProxy is a type of AJAX proxy, and WindchillXml is a type of XML reader.

TreeModel config:

Ext.define('LabData.model.LabTreeNode', {
extend: 'Ext.data.TreeModel',
requires: ['LabData.data.proxy.WindchillProxy'],
idProperty: 'Oid',
fields: [{
name: 'Oid'
}, {
name: 'parentId',
mapping: 'ParentOid'
}, {
name: 'Name'
}, {
name: 'Number'
}, {
name: 'Description'
}, {
name: 'DocClass'
}, {
name: 'DocType'
}, {
name: 'expandable',
type: 'boolean',
defaultValue: true
}, {
name: 'expanded',
type: 'boolean',
defaultValue: false
}, {
name: 'leaf',
type: 'boolean',
defaultValue: false
}]
});
The initial load request is sent to "...servlet/IE/tasks/ext/TACOM/labdata/readChildren.xml?_dc=...&Oid=", and it returns the following:


<?xml version="1.0" encoding="UTF-8"?>
<wc:COLLECTION xmlns:wc="http://www.ptc.com/infoengine/1.0">
<Children NAME="Children" TYPE="Object" STATUS="0">
<wc:INSTANCE CLASS="Data">
<Oid>VR:wt.doc.WTDocument:1348534131</Oid>
<Name>Test Lab 1</Name>
<Description>...</Description>
<DocClass>...</DocClass>
<DocType>...</DocType>
<Number>...</Number>
</wc:INSTANCE>
</Children>
</wc:COLLECTION>
I'm expecting a request to be sent to "...servlet/IE/tasks/ext/TACOM/labdata/readChildren.xml?_dc=...&Oid=VR:wt.doc.WTDocument:1348534131" when that node is expanded, but no request is made. What am I missing?

Carlos_hb
15 Apr 2014, 9:12 AM
I once tried one and had some different configurations, in the root config from the treestore, i have expanded true and other parameter called loaded: true.I don't think that will change but it's the only thing you have different from meHope to help

adavis2
15 Apr 2014, 9:33 AM
I once tried one and had some different configurations, in the root config from the treestore, i have expanded true and other parameter called loaded: true.I don't think that will change but it's the only thing you have different from meHope to help
Thanks for your help. I have it working now. There is a problem in the custom WindchillXml reader code (not posted), which wasn't designed to be used by a TreeStore. I replaced the TreeStore config with this:

Ext.define('LabData.store.LabTreeStore', {
extend: 'Ext.data.TreeStore',
storeId: 'LabTreeStore',
autoLoad: false,
model: 'LabData.model.LabTreeNode',
nodeParam: 'Oid',
root: {
expanded: false,
Name: 'Laboratories',
Oid: null
},
proxy: {
type: 'WindchillProxy',
api: {
read: 'servlet/IE/tasks/ext/TACOM/labdata/readChildren.xml'
},
reader: {
type: 'xml',
root: 'Children',
record: '[CLASS=Data]'
}
}
});
The on-demand loading is working now.