1. #1
    Sencha User JamieMason's Avatar
    Join Date
    Apr 2010
    Location
    Leeds, UK
    Posts
    42
    Vote Rating
    0
    JamieMason is on a distinguished road

      0  

    Default Answered: Equivalent of Ext.data.reader.Reader.readRecords when creating Model directly?

    Answered: Equivalent of Ext.data.reader.Reader.readRecords when creating Model directly?


    I'm in a sorry position where I have to transform the data I'm getting so it's workable, I've overridden Ext.data.reader.Reader.readRecords to do this when the data comes in from the Server.

    I'm writing unit tests for this code at the moment and in those I'm using Ext.create to instantiate my test stubs. When calling Ext.create though, the Ext.data.reader.* isn't involved.

    Is there an equivalent method which transforms the data passed to Ext.create?

    Code:
    Ext.define('SomeModel', {    extend: 'Ext.data.Model'
        , proxy: {
            type: 'ajax'
            , url: 'http://etc'
            , reader: {
                type: 'json'
                , readRecords: function (suckyJson)
                {
                    var somethingICanUse = [];
                    
                    // Herd cats
                    
                    return new Ext.data.ResultSet({
                        records: somethingICanUse
                        , success: true
                        , total: somethingICanUse.length
                        , count: somethingICanUse.length
                    });
                }
            }
        }
        , fields: [
            // my fields
        ]
    });
    Thanks.

  2. This thread is vaguely related:

    http://www.sencha.com/forum/showthread.php?144756

    Thought occurs that for testing the reader you could try using a memory proxy:

    http://docs.sencha.com/ext-js/4-0/#!...a.proxy.Memory

    That said, I don't really understand why you'd need to use the real reader and fake models in the same unit test. Seems a bit odd to me.

  3. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,592
    Answers
    541
    Vote Rating
    323
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    This thread is vaguely related:

    http://www.sencha.com/forum/showthread.php?144756

    Thought occurs that for testing the reader you could try using a memory proxy:

    http://docs.sencha.com/ext-js/4-0/#!...a.proxy.Memory

    That said, I don't really understand why you'd need to use the real reader and fake models in the same unit test. Seems a bit odd to me.

  4. #3
    Sencha User JamieMason's Avatar
    Join Date
    Apr 2010
    Location
    Leeds, UK
    Posts
    42
    Vote Rating
    0
    JamieMason is on a distinguished road

      0  

    Default


    Thanks again Skirtle

Thread Participants: 1

Tags for this Thread