-
9 Dec 2011 9:13 AM #1
Tree Store does not function with XML Reader
Tree Store does not function with XML Reader
Just as the title states the XML reader does not function with a Tree Store. I have yet to see any examples of XML being used with a Tree Store so this was probably over looked at some time. Anyway, below you will find all the files associated with the test case including a json data set that does function properly.
That said, I have done some debugging already. There seems to be a number of issues but the most obvious will be a call to Ext,.DomQuery.isXml() inside of the XML Reader. The function being called does not exist. However, upon removing that the call to Ext.DomQuery.selectNode() issues the error that the second argument which is suppose to be a dom node does not have the method querySelectorAll. Upon further debugging dumping the data element to the console it is the root node defined in the tree store, not part of XML returned from the request. So it seems like when the request data is read the root level element of the XML file needs to be passed to the reader rather than the root defined in the store (most likely a object literal). That is as far as I have been able to get with it. Hope it helps.
Thanks
test_case_tree_xml_bug.js
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: 'title', 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.json', reader: { type: 'json', root: 'categories' } } works */ proxy: { type: 'ajax', url : 'test_case_tree_xml_bug.xml', reader: { type: 'xml', root: 'categories' } } }); Ext.define('TreeXmlBug.view.NestedList',{ extend: 'Ext.dataview.NestedList', xtype: 'mynestedlist', config: { title: 'Test Case: XML Bug', store: Ext.create('TreeXmlBug.store.Data'), displayField: 'title' }, getItemTextTpl: function() { return '{' + this.getDisplayField() + '}'; } }); Ext.application({ name: 'TreeXMLBug', launch: function() { Ext.widget('panel',{ fullscreen: true, layout: 'fit', items: [{xtype: 'mynestedlist'}] }); } });
test_case_tree_xml_bug.jsonCode:<?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> </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>
Code:{"total":"179","success":true,"fault":"","categories":[{"id":"15347","title":"Births","parent_id":null,"leaf":"1","categories":[]},{"id":"15727","title":"Grovetown Warriors","parent_id":null,"leaf":"1","categories":[]},{"id":"10898","title":"225 Section","parent_id":null,"leaf":"1","categories":[]},{"id":"14881","title":"ASU2011","parent_id":null,"leaf":"1","categories":[]},{"id":"12471","title":"chronicle-events","parent_id":null,"leaf":"1","categories":[]},{"id":"12346","title":"Masters News","parent_id":null,"leaf":"1","categories":[]},{"id":"12662","title":"Osama bin Laden","parent_id":null,"leaf":"1","categories":[]},{"id":"8865","title":"Back To School","parent_id":null,"leaf":"1","categories":[]},{"id":"8952","title":"Multimedia","parent_id":null,"leaf":"1","categories":[]},{"id":"8683","title":"Corrections","parent_id":null,"leaf":"1","categories":[]},{"id":"6816","title":"Latest News","parent_id":null,"leaf":"1","categories":[]},{"id":"31","title":"Opinion","parent_id":null,"leaf":"0","categories":[{"id":"63","title":"Cartoons","parent_id":"31","leaf":"1","categories":[]},{"id":"33","title":"Editorials","parent_id":"31","leaf":"1","categories":[]},{"id":"32","title":"Letters","parent_id":"31","leaf":"1","categories":[]},{"id":"248","title":"Opinion columns","parent_id":"31","leaf":"1","categories":[]}]},{"id":"1","title":"News","parent_id":null,"leaf":"0","categories":[{"id":"8812","title":"Aiken","parent_id":"1","leaf":"1","categories":[]},{"id":"11454","title":"We Think Pink","parent_id":"1","leaf":"1","categories":[]},{"id":"8814","title":"Bizarre","parent_id":"1","leaf":"1","categories":[]},{"id":"36","title":"Business","parent_id":"1","leaf":"0","categories":[{"id":"10937","title":"Local Business","parent_id":"36","leaf":"1","categories":[]},{"id":"250","title":"Your Business","parent_id":"36","leaf":"1","categories":[]},{"id":"14818","title":"Smart Shopper","parent_id":"36","leaf":"1","categories":[]},{"id":"97","title":"Finance","parent_id":"36","leaf":"1","categories":[]},{"id":"10004","title":"Biz Bits","parent_id":"36","leaf":"1","categories":[]}]},{"id":"8811","title":"Hurricane","parent_id":"1","leaf":"1","categories":[]},{"id":"8813","title":"Iraq","parent_id":"1","leaf":"1","categories":[]},{"id":"8449","title":"Crime courts","parent_id":"1","leaf":"1","categories":[]},{"id":"8450","title":"Government","parent_id":"1","leaf":"0","categories":[{"id":"107","title":"City Ink","parent_id":"8450","leaf":"1","categories":[]},{"id":"10136","title":"Elections","parent_id":"8450","leaf":"0","categories":[{"id":"10420","title":"Georgia Elections","parent_id":"10136","leaf":"0","categories":[{"id":"10422","title":"Georgia Governor","parent_id":"10420","leaf":"1","categories":[]},{"id":"10424","title":"Georgia Legislature","parent_id":"10420","leaf":"1","categories":[]},{"id":"10428","title":"Georgia Local","parent_id":"10420","leaf":"1","categories":[]},{"id":"10430","title":"Georgia National","parent_id":"10420","leaf":"1","categories":[]},{"id":"10426","title":"Georgia Statewide","parent_id":"10420","leaf":"1","categories":[]}]},{"id":"10421","title":"South Carolina Elections","parent_id":"10136","leaf":"0","categories":[{"id":"10423","title":"South Carolina Governor","parent_id":"10421","leaf":"1","categories":[]},{"id":"10425","title":"South Carolina Legislature","parent_id":"10421","leaf":"1","categories":[]},{"id":"10429","title":"South Carolina Local","parent_id":"10421","leaf":"1","categories":[]},{"id":"10431","title":"South Carolina National","parent_id":"10421","leaf":"1","categories":[]},{"id":"10427","title":"South Carolina Statewide","parent_id":"10421","leaf":"1","categories":[]}]}]}]},{"id":"8448","title":"Education","parent_id":"1","leaf":"0","categories":[{"id":"1221","title":"Back to school","parent_id":"8448","leaf":"1","categories":[]}]},{"id":"8690","title":"Health","parent_id":"1","leaf":"1","categories":[]},{"id":"2","title":"Metro","parent_id":"1","leaf":"1","categories":[]},{"id":"214","title":"National","parent_id":"1","leaf":"1","categories":[]},{"id":"77","title":"Richmond Neighbors","parent_id":"1","leaf":"1","categories":[]},{"id":"8864","title":"Technology","parent_id":"1","leaf":"1","categories":[]},{"id":"8689","title":"Weather","parent_id":"1","leaf":"1","categories":[]},{"id":"161","title":"World","parent_id":"1","leaf":"1","categories":[]},{"id":"35","title":"Bill Kirby","parent_id":"1","leaf":"1","categories":[]},{"id":"113","title":"Glynn Moore","parent_id":"1","leaf":"1","categories":[]}]},{"id":"25","title":"Things to Do","parent_id":null,"leaf":"0","categories":[{"id":"84","title":"Applause","parent_id":"25","leaf":"1","categories":[]},{"id":"11342","title":"Westobou","parent_id":"25","leaf":"1","categories":[]},{"id":"9181","title":"Cher Best","parent_id":"25","leaf":"1","categories":[]},{"id":"9180","title":"Ed Turner","parent_id":"25","leaf":"1","categories":[]},{"id":"8972","title":"entertainment","parent_id":"25","leaf":"1","categories":[]},{"id":"80","title":"Arts","parent_id":"25","leaf":"1","categories":[]},{"id":"8685","title":"Going out","parent_id":"25","leaf":"0","categories":[{"id":"78","title":"Music","parent_id":"8685","leaf":"1","categories":[]},{"id":"8686","title":"Nightlife","parent_id":"8685","leaf":"1","categories":[]}]},{"id":"26","title":"Movies","parent_id":"25","leaf":"0","categories":[{"id":"1067","title":"Oscars","parent_id":"26","leaf":"1","categories":[]}]},{"id":"82","title":"Ramblin' Rhodes","parent_id":"25","leaf":"1","categories":[]},{"id":"83","title":"Steven Uhles","parent_id":"25","leaf":"1","categories":[]},{"id":"30","title":"Television","parent_id":"25","leaf":"1","categories":[]}]},{"id":"22","title":"Life","parent_id":null,"leaf":"0","categories":[{"id":"7760","title":"Aspire","parent_id":"22","leaf":"1","categories":[]},{"id":"8682","title":"Fashion","parent_id":"22","leaf":"1","categories":[]},{"id":"8681","title":"People","parent_id":"22","leaf":"1","categories":[]},{"id":"8677","title":"Home","parent_id":"22","leaf":"0","categories":[{"id":"24","title":"Gardening","parent_id":"8677","leaf":"1","categories":[]},{"id":"8687","title":"Real estate","parent_id":"8677","leaf":"1","categories":[]}]},{"id":"157","title":"Diet","parent_id":"22","leaf":"1","categories":[]},{"id":"54","title":"Food","parent_id":"22","leaf":"0","categories":[{"id":"8680","title":"Recipes","parent_id":"54","leaf":"1","categories":[]},{"id":"8679","title":"Wine","parent_id":"54","leaf":"1","categories":[]},{"id":"60","title":"Karin Calloway","parent_id":"54","leaf":"1","categories":[]}]},{"id":"253","title":"Pets","parent_id":"22","leaf":"1","categories":[]},{"id":"29","title":"Xtreme","parent_id":"22","leaf":"1","categories":[]},{"id":"27","title":"Your Faith","parent_id":"22","leaf":"1","categories":[]},{"id":"474","title":"Autos","parent_id":"22","leaf":"1","categories":[]},{"id":"23","title":"Life style","parent_id":"22","leaf":"1","categories":[]}]},{"id":"9","title":"Sports","parent_id":null,"leaf":"0","categories":[{"id":"46","title":"Baseball","parent_id":"9","leaf":"0","categories":[{"id":"13","title":"Braves","parent_id":"46","leaf":"1","categories":[]},{"id":"51","title":"GreenJackets","parent_id":"46","leaf":"1","categories":[]}]},{"id":"1047","title":"Futurity","parent_id":"9","leaf":"1","categories":[]},{"id":"71","title":"Clemson","parent_id":"9","leaf":"1","categories":[]},{"id":"92","title":"College","parent_id":"9","leaf":"0","categories":[{"id":"8959","title":"ASU","parent_id":"92","leaf":"1","categories":[]},{"id":"12197","title":"USCA","parent_id":"92","leaf":"1","categories":[]}]},{"id":"160","title":"David Westin","parent_id":"9","leaf":"1","categories":[]},{"id":"127","title":"Georgia Southern sports","parent_id":"9","leaf":"1","categories":[]},{"id":"75","title":"Georgia Tech","parent_id":"9","leaf":"1","categories":[]},{"id":"18","title":"Golf","parent_id":"9","leaf":"1","categories":[]},{"id":"53","title":"High school","parent_id":"9","leaf":"1","categories":[]},{"id":"12291","title":"Signing Day","parent_id":"9","leaf":"1","categories":[]},{"id":"189","title":"Hockey","parent_id":"9","leaf":"0","categories":[{"id":"10354","title":"RiverHawks","parent_id":"189","leaf":"1","categories":[]},{"id":"85","title":"Lynx","parent_id":"189","leaf":"1","categories":[]}]},{"id":"20","title":"Nascar","parent_id":"9","leaf":"1","categories":[]},{"id":"21","title":"NBA","parent_id":"9","leaf":"1","categories":[]},{"id":"10","title":"NFL","parent_id":"9","leaf":"1","categories":[]},{"id":"146","title":"Olympics","parent_id":"9","leaf":"1","categories":[]},{"id":"11","title":"Other sports","parent_id":"9","leaf":"1","categories":[]},{"id":"96","title":"Outdoors","parent_id":"9","leaf":"0","categories":[{"id":"101","title":"Fishing","parent_id":"96","leaf":"1","categories":[]},{"id":"259","title":"Rob Pavey","parent_id":"96","leaf":"1","categories":[]}]},{"id":"73","title":"Scott Michaux","parent_id":"9","leaf":"1","categories":[]},{"id":"50","title":"Spartans","parent_id":"9","leaf":"1","categories":[]},{"id":"48","title":"UGA","parent_id":"9","leaf":"1","categories":[]},{"id":"45","title":"USC","parent_id":"9","leaf":"1","categories":[]}]},{"id":"8698","title":"Commentary","parent_id":null,"leaf":"1","categories":[]},{"id":"8866","title":"Community Chronicle","parent_id":null,"leaf":"1","categories":[]},{"id":"10031","title":"gear and gadgets","parent_id":null,"leaf":"1","categories":[]},{"id":"10361","title":"Graduations","parent_id":null,"leaf":"0","categories":[{"id":"10378","title":"2010 Best and Brightest","parent_id":"10361","leaf":"1","categories":[]},{"id":"14739","title":"2011 Best and Brightest","parent_id":"10361","leaf":"1","categories":[]},{"id":"14738","title":"2011 High School Graduations","parent_id":"10361","leaf":"1","categories":[]},{"id":"10379","title":"2010 High School Graduations","parent_id":"10361","leaf":"1","categories":[]}]},{"id":"8867","title":"James Brown","parent_id":null,"leaf":"1","categories":[]},{"id":"8810","title":"Living","parent_id":null,"leaf":"1","categories":[]},{"id":"11135","title":"Aiken Hornets","parent_id":null,"leaf":"1","categories":[]},{"id":"15201","title":"Augusta Prep Cavaliers","parent_id":null,"leaf":"1","categories":[]},{"id":"11852","title":"college basketball","parent_id":null,"leaf":"1","categories":[]},{"id":"7776","title":"Latest-Removed","parent_id":null,"leaf":"1","categories":[]},{"id":"11136","title":"Aquinas Fighting Irish","parent_id":null,"leaf":"1","categories":[]},{"id":"8974","title":"Ramblin Rhodes","parent_id":null,"leaf":"1","categories":[]},{"id":"11168","title":"Thomson Bulldogs","parent_id":null,"leaf":"1","categories":[]},{"id":"11189","title":"Curtis Baptist Crusaders","parent_id":null,"leaf":"1","categories":[]},{"id":"11146","title":"Glascock County Panthers","parent_id":null,"leaf":"1","categories":[]},{"id":"11158","title":"Lincoln County Red Devils","parent_id":null,"leaf":"1","categories":[]},{"id":"11169","title":"Wagener-Salley War Eagles","parent_id":null,"leaf":"1","categories":[]},{"id":"11190","title":"Westminster Wildcats","parent_id":null,"leaf":"1","categories":[]},{"id":"8","title":"Obituaries","parent_id":null,"leaf":"1","categories":[]},{"id":"11147","title":"Glenn Hills Spartans","parent_id":null,"leaf":"1","categories":[]},{"id":"11159","title":"McCormick Chiefs","parent_id":null,"leaf":"1","categories":[]},{"id":"11170","title":"Warren County Screaming Devils","parent_id":null,"leaf":"1","categories":[]},{"id":"11137","title":"Augusta Christian Lions","parent_id":null,"leaf":"1","categories":[]},{"id":"11191","title":"Swainsboro Tigers","parent_id":null,"leaf":"1","categories":[]},{"id":"11148","title":"Greenbrier Wolfpack","parent_id":null,"leaf":"1","categories":[]},{"id":"11160","title":"Midland Valley Mustangs","parent_id":null,"leaf":"1","categories":[]},{"id":"11171","title":"Washington County Golden Hawks","parent_id":null,"leaf":"1","categories":[]},{"id":"11138","title":"Barnwell Warhorses","parent_id":null,"leaf":"1","categories":[]},{"id":"11149","title":"Grovetown Warriors","parent_id":null,"leaf":"1","categories":[]},{"id":"11161","title":"North Augusta Yellow Jackets","parent_id":null,"leaf":"1","categories":[]},{"id":"11172","title":"Washington-Wilkes Tigers","parent_id":null,"leaf":"1","categories":[]},{"id":"11139","title":"Blackville-Hilda Hawks","parent_id":null,"leaf":"1","categories":[]},{"id":"11150","title":"Harlem Bulldogs","parent_id":null,"leaf":"1","categories":[]},{"id":"11162","title":"Richmond Academy Musketeers","parent_id":null,"leaf":"1","categories":[]},{"id":"11173","title":"Westside Patriots","parent_id":null,"leaf":"1","categories":[]},{"id":"11140","title":"Briarwood Academy Buccaneers","parent_id":null,"leaf":"1","categories":[]},{"id":"11151","title":"Hephzibah Rebels","parent_id":null,"leaf":"1","categories":[]},{"id":"11163","title":"Ridge Spring-Monetta Trojans","parent_id":null,"leaf":"1","categories":[]},{"id":"11174","title":"Williston-Elko Blue Devils","parent_id":null,"leaf":"1","categories":[]},{"id":"11141","title":"Burke County Bears","parent_id":null,"leaf":"1","categories":[]},{"id":"11153","title":"Jefferson County Warriors","parent_id":null,"leaf":"1","categories":[]},{"id":"11164","title":"Screven County Gamecocks","parent_id":null,"leaf":"1","categories":[]},{"id":"11175","title":"Thomas Jefferson Jaguars","parent_id":null,"leaf":"1","categories":[]},{"id":"11142","title":"Butler Bulldogs","parent_id":null,"leaf":"1","categories":[]},{"id":"11154","title":"Jenkins County Eagles","parent_id":null,"leaf":"1","categories":[]},{"id":"11165","title":"Silver Bluff Bulldogs","parent_id":null,"leaf":"1","categories":[]},{"id":"10618","title":"ASU Golf NCAA Championship","parent_id":null,"leaf":"1","categories":[]},{"id":"11176","title":"Wardlaw Patriots","parent_id":null,"leaf":"1","categories":[]},{"id":"11143","title":"Cross Creek Razorbacks","parent_id":null,"leaf":"1","categories":[]},{"id":"11155","title":"Josey Eagles","parent_id":null,"leaf":"1","categories":[]},{"id":"11166","title":"South Aiken Thoroughbreds","parent_id":null,"leaf":"1","categories":[]},{"id":"11177","title":"Brentwood Eagles","parent_id":null,"leaf":"1","categories":[]},{"id":"11144","title":"Evans Knights","parent_id":null,"leaf":"1","categories":[]},{"id":"11156","title":"Lakeside Panthers","parent_id":null,"leaf":"1","categories":[]},{"id":"11167","title":"Strom Thurmond Rebels","parent_id":null,"leaf":"1","categories":[]},{"id":"11178","title":"Edmund Burke Spartans","parent_id":null,"leaf":"1","categories":[]},{"id":"11145","title":"Fox Creek Predators","parent_id":null,"leaf":"1","categories":[]},{"id":"11157","title":"Laney Wildcats","parent_id":null,"leaf":"1","categories":[]}]}
-
9 Dec 2011 10:42 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,617
- Vote Rating
- 435
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
9 Dec 2011 11:18 AM #3
That is the most obvious issue but not the only one. The primary issue is that the root node is being passed to the reader rather than the XML document. So I urge you to reopen the thread.
Originally Posted by oddz
-
9 Dec 2011 11:28 AM #4
Override the getRoot() function and the next error will become obvious.
Code:Ext.define('TreeXmlBug.data.reader.XmlOverride',{ override: 'Ext.data.reader.Xml', getRoot: function(data) { var nodeName = data.nodeName, root = this.root; if (!root || (nodeName && nodeName == root)) { return data; } else { return Ext.DomQuery.selectNode(root, data); } } });
Looks like we can't reproduce the issue or there's a problem in the test case provided.


Reply With Quote