Results 1 to 3 of 3

Thread: [STALE-462][3.1] XmlWriter render bug

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Ext User
    Join Date
    Nov 2009
    Posts
    16
    Vote Rating
    0
      0  

    Default [STALE-462][3.1] XmlWriter render bug

    Ext version tested:

    • Ext 3.1.0

    Adapter used:

    • ext

    css used:

    • only default ext-all.css

    Browser versions tested against:

    • FF3.5.7 (firebug 1.4.5 installed)

    Operating System:

    • WinXP

    Description:

    • 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:
    Code:
    var params = {};
    var baseParams = {};      
    var allRecords = [];
    myStore.writer.apply(params, baseParams, 'update', allRecords);
    params.xmlData is:
    <root>
    <element></element>
    </root>

    instead of
    <root>
    </root>

    Fix:
    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]
            });
        }
    (last line changed)

  2. #2
    Ext User dayext's Avatar
    Join Date
    Jul 2008
    Location
    Basel, Switzerland
    Posts
    46
    Vote Rating
    0
      0  

    Default

    Shouldn't the isArray check be on data and not on its first element?

    Code:
    records: Ext.isArray(data) ? data : [data]
    This way you don't need the length check, since empty arrays will be passed through as empty arrays.

    (Note: not tested, pure theory)
    Day Ext Developers

  3. #3
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    18,436
    Vote Rating
    859
      0  

    Default

    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •