-
6 Jan 2012 12:45 PM #1
Tree and/or NestedList Not Functioning With XML Reader
Tree and/or NestedList Not Functioning With XML Reader
The tree and/or nested list does not seem to function when using a store with an XML reader.
test_case_tree_xml_bug.xmlCode:Ext.Loader.setConfig({ enabled: true }); Ext.define('TreeXmlBug.model.Data',{ extend: 'Ext.data.Model', fields: [ {name: 'id', type: 'int'}, {name: 'name', type: 'string'} ] }); Ext.define('TreeXmlBug.store.Data',{ extend: 'Ext.data.TreeStore', model: 'TreeXmlBug.model.Data', requires: ['TreeXmlBug.model.Data'], autoLoad: true, remoteFilter: false, remoteSort: false, root: {}, proxy: { type: 'ajax', url : 'test_case_tree_xml_bug.xml', reader: { type: 'xml', root: 'categories', record: 'category' } } }); Ext.define('TreeXmlBug.view.NestedList',{ extend: 'Ext.dataview.NestedList', xtype: 'mynestedlist', config: { title: 'Test Case: XML Bug', store: Ext.create('TreeXmlBug.store.Data'), displayField: 'name' }, getItemTextTpl: function() { return '{' + this.getDisplayField() + '}'; } }); Ext.application({ name: 'TreeXMLBug', launch: function() { Ext.widget('panel',{ fullscreen: true, layout: 'fit', items: [{xtype: 'mynestedlist'}] }); } });
Code:<?xml version="1.0"?> <categories> <category> <id>1</id> <name>News</name> <categories> <category> <id>2</id> <name>Local</name> </category> <category> <id>6816</id> <name>Latest Updates</name> </category> <category> <id>8449</id> <name>Crime & Courts</name> </category> <category> <id>11454</id> <name>We Think Pink</name> </category> <category> <id>8450</id> <name>Government</name> </category> <category> <id>107</id> <name>City Ink</name> </category> <category> <id>8448</id> <name>Schools</name> </category> <category> <id>8690</id> <name>Health</name> </category> <category> <id>8814</id> <name>Bizarre</name> <leaf>1</leaf> </category> </categories> </category> <category> <id>9</id> <name>Sports</name> <categories> <category> <id>53</id> <name>Preps</name> </category> <category> <id>92</id> <name>College</name> </category> </categories> </category> </categories>
-
6 Jan 2012 12:50 PM #2
This is my attempt to begin debugging the issue myself but things are not going so smoothly. As you can see all the categories are being displayed at the root level.
Code:Ext.Loader.setConfig({ enabled: true }); /* ----------------------------------------------------------------------------- My attempt to hack aorund this issue ------------------------------------------------------------------------------- */ Ext.define('TreeXmlBug.data.reader.XmlOverride',{ override: 'Ext.data.reader.Xml', getRoot: function(data) { // console.log(data); var nodeName = data.nodeName, root = this.root; if (!root || (nodeName && nodeName == root)) { return data; } else { return Ext.DomQuery.selectNode(root, data); } } }); Ext.define('TreeXmlBug.data.TreeStoreOverride',{ override: 'Ext.data.TreeStore', onNodeAdded: function(parent, node) { if(!parent) { return; } var proxy = this.getProxy(), reader = proxy.getReader(), data = node.raw || node.data, dataRoot, children; Ext.Array.remove(this.removed, node); if (!node.isLeaf() && !node.isLoaded() ) { dataRoot = reader.getRoot(data); if (dataRoot) { this.fillNode(node, reader.extractData(dataRoot)); delete data[reader.root]; } } } /*onProxyLoad: function(operation) { console.log(operation.node); console.log(operation.getRecords()); this.callParent(arguments); }*/ }); /* ----------------------------------------------------------------------------- End my attempt to hack aorund this issue ------------------------------------------------------------------------------- */ Ext.define('TreeXmlBug.model.Data',{ extend: 'Ext.data.Model', fields: [ {name: 'id', type: 'int'}, {name: 'name', type: 'string'} ] }); Ext.define('TreeXmlBug.store.Data',{ extend: 'Ext.data.TreeStore', model: 'TreeXmlBug.model.Data', requires: ['TreeXmlBug.model.Data'], autoLoad: true, remoteFilter: false, remoteSort: false, root: {}, proxy: { type: 'ajax', url : 'test_case_tree_xml_bug.xml', reader: { type: 'xml', root: 'categories', record: 'category' } } }); Ext.define('TreeXmlBug.view.NestedList',{ extend: 'Ext.dataview.NestedList', xtype: 'mynestedlist', config: { title: 'Test Case: XML Bug', store: Ext.create('TreeXmlBug.store.Data'), displayField: 'name' }, getItemTextTpl: function() { return '{' + this.getDisplayField() + '}'; } }); Ext.application({ name: 'TreeXMLBug', launch: function() { Ext.widget('panel',{ fullscreen: true, layout: 'fit', items: [{xtype: 'mynestedlist'}] }); } });
-
9 Jan 2012 9:15 AM #3Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Redwood City, California
- Posts
- 3,659
- Vote Rating
- 14
Thank you for the report.
You found a bug! We've classified it as
TOUCH-1351
.
We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.


Reply With Quote