-
21 Jan 2010 12:37 AM #1
[STALE-462][3.1] XmlWriter render bug
[STALE-462][3.1] XmlWriter render bug
Ext version tested:
- Ext 3.1.0
- ext
- only default ext-all.css
- FF3.5.7 (firebug 1.4.5 installed)
- WinXP
- If you call the render method in XMLWriter with no data(records), it renders an empty record in params.xmlData instead of no record
Test Case:
params.xmlData is:Code:var params = {}; var baseParams = {}; var allRecords = []; myStore.writer.apply(params, baseParams, 'update', allRecords);
<root>
<element></element>
</root>
instead of
<root>
</root>
Fix:
(last line changed)Code:render : function(params, baseParams, data) { baseParams = this.toArray(baseParams); params.xmlData = this.tpl.applyTemplate({ version: this.xmlVersion, encoding: this.xmlEncoding, documentRoot: (baseParams.length > 0 || this.forceDocumentRoot === true) ? this.documentRoot : false, record: this.meta.record, root: this.root, baseParams: baseParams, // records: (Ext.isArray(data[0])) ? data : [data] records: (Ext.isArray(data[0]) || data.length == 0) ? data : [data] }); }
-
28 Jan 2010 5:55 AM #2
Shouldn't the isArray check be on data and not on its first element?
This way you don't need the length check, since empty arrays will be passed through as empty arrays.Code:records: Ext.isArray(data) ? data : [data]
(Note: not tested, pure theory)Day Ext Developers
-
31 Jan 2010 7:02 PM #3
Care to post a full test case? I can't replicate the behaviour:
Code:Ext.onReady(function(){ var store = new Ext.data.Store({ reader: new Ext.data.XmlReader({ record: 'root' }, [{ fields: 'f1' }]), writer: new Ext.data.XmlWriter() }); var params = {}; var baseParams = {}; var allRecords = []; store.writer.apply(params, baseParams, 'update', allRecords); console.log(params); });Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
Thank you for reporting this bug. We will make it our priority to review this report.


Reply With Quote