1. #1
    Ext JS Premium Member
    Join Date
    Aug 2011
    Posts
    37
    Answers
    1
    Vote Rating
    0
    jakobgrannas is on a distinguished road

      0  

    Default Answered: Ext.data.Operation Read method problem

    Answered: Ext.data.Operation Read method problem


    Hi,

    I am using a method similar to model.load() and when I try to execute that method, the code breaks inside the Ext.data.Operation processRead method. I get an error saying "typeerror: object is not a function" when trying to execute this code (sencha-touch-all-debug.js):


    Code:
     processRead: function(resultSet) {
            var records = resultSet.getRecords(),
                processedRecords = [],
                Model = this.getModel(),
                ln = records.length,
                i, record;
    
    
            for (i = 0; i < ln; i++) {
                record = records[i];
                processedRecords.push(new Model(record.data, record.id, record.node));  <--- Breaks here
            }
    
    
            this.setRecords(processedRecords);
            return true;
        },
    So for some reason instatiation of Model is not possible. I tried evaluating the expression (new Model) in WebStorm and got the same error message as above ("typeerror: object is not a function")

    This is my "load" code and my model:

    Code:
    Ext.define('Intelliplan.Base.Data.Query', {
        extend: 'Ext.data.Model',
        execute: function(params, successHandler, scope) {
    
    
            var config = {
                action: 'read',
                params: params,
                model: this
            };
    
    
            var operation = Ext.create('Ext.data.Operation', config),
            proxy = this.getProxy(),
            record = null,
            callback;
    
    
            callback = function(operation) {
                if (operation.wasSuccessful()) {
                    var result;
                    if(proxy.dataType === 'list'){
                        result = operation.getRecords();
                    }else{
                        result = operation.getRecords()[0];
                    }
                    Ext.callback(successHandler, scope, [result, operation]);
                }else{
                    
                }
                /*  TODO implement handlers for other than success {
                    Ext.callback(config.failure, scope, [record, operation]);
                }
                Ext.callback(config.callback, scope, [record, operation]);*/
            };
    
    
            proxy.read(operation, callback, this);
        }
    });
    Model:
    Code:
    Ext.define('Intelliplan.Data.System.Session.Query.SessionConfiguration', {
        extend: 'Intelliplan.Base.Data.Query',
        config: {
        idProperty: 'id',
        proxy: Ext.create('Intelliplan.Base.Proxy.Standard', {
            url: Intelliplan.Api.BaseUrl + '/System/Session/GetSessionConfiguration'
        }),
        fields: [
            {
                name: 'userId'
            },
            {
                name: 'languageCode'
            },
            {
                name: 'formats'
            },
            {
                name: 'calendar'
            },
            {
                name: 'phrases'
            },
            {
                name: 'firstName'
            },
            {
                name: 'surName'
            },
            {
                name: 'fullName'
            },
            {
                name: 'userCompanyNo'
            },
            {
                name: 'userCompanyName'
            },
            {
                name: 'features'
            }
        ]
        }
    });
    So basically my question is: Is this a bug or am I doing something wrong?

  2. Try changing this to:

    Code:
    Ext.define('Intelliplan.Base.Data.Query', {
        extend: 'Ext.data.Model',
        execute: function(params, successHandler, scope) {
    
    
            var config = {
                action: 'read',
                params: params,
                model: this.self
            };
    
    
            var operation = Ext.create('Ext.data.Operation', config)
            ...

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,780
    Answers
    3465
    Vote Rating
    833
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    What does Model equate to?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Ext JS Premium Member
    Join Date
    Aug 2011
    Posts
    37
    Answers
    1
    Vote Rating
    0
    jakobgrannas is on a distinguished road

      0  

    Default


    I'm not at work at the moment, so I can't check for sure, but it's an object (I think it's a model) containing (from what I can remember):

    data (contains all the fields defined in the model. Field properties are all empty, as they should be)
    node (same, I think)
    id: null (not 100% sure about this one)
    raw: don't remember
    ...Some other stuff I can't remember

    I realize that this might not be very helpful, so I'll get back to you when I know for sure what Model contains.

  5. #4
    Sencha User
    Join Date
    Mar 2007
    Location
    Haarlem, Netherlands
    Posts
    1,243
    Answers
    28
    Vote Rating
    10
    TommyMaintz will become famous soon enough TommyMaintz will become famous soon enough

      0  

    Default


    Try changing this to:

    Code:
    Ext.define('Intelliplan.Base.Data.Query', {
        extend: 'Ext.data.Model',
        execute: function(params, successHandler, scope) {
    
    
            var config = {
                action: 'read',
                params: params,
                model: this.self
            };
    
    
            var operation = Ext.create('Ext.data.Operation', config)
            ...

  6. #5
    Ext JS Premium Member
    Join Date
    Aug 2011
    Posts
    37
    Answers
    1
    Vote Rating
    0
    jakobgrannas is on a distinguished road

      0  

    Default


    Quote Originally Posted by TommyMaintz View Post
    Try changing this to:

    Code:
    Ext.define('Intelliplan.Base.Data.Query', {
        extend: 'Ext.data.Model',
        execute: function(params, successHandler, scope) {
    
    
            var config = {
                action: 'read',
                params: params,
                model: this.self
            };
    
    
            var operation = Ext.create('Ext.data.Operation', config)
            ...
    EDIT: It worked! Thanks a lot! Would you mind explaining why it worked?

Thread Participants: 2

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi