0
votes

I'm getting this error:

[E] Ext.data.Session.checkModelType(): Unable to use anonymous models in a Session

when trying to use a Session when binding a Grid with a Store via ViewModel:

ViewModel:

Ext.define('App.view.gridViewModel', { 
        extend: 'Ext.app.ViewModel', 
        alias: 'viewmodel.gridview', 

         stores:{ 
                 gridstore: { 
                         model: 'gridView', 
                         autoLoad: true, 
                         //This triggers the Exception: 
                         session: true, 
                         listeners: { 
                                beforeload: function(store, operation, eOpts) { 
                                        var oProxy = this.getProxy(); 
                                        oProxy.setExtraParams({ 
                                                tableName: 'dbo.SomeTable' 
                                                , identityKey: "id" 
                                                , primaryKey: ["id"] 
                                                , mode: "readonly" 
                                                , lang: "es" 
                                                , output: 'json' 
                                        }); 
                                } 
                         } 
                 } 
         } 
});  

View:

Ext.define('App.view.gridView', { 
        extend: 'Ext.form.Panel', 

        //... 

        viewModel: { 
                type: 'gridview' 
        }, 

        controller: 'gridview', 

        // Create a session for this view 
        session:true, 

        items: [{ 
                xtype: 'grid', 
                reference: 'myGrid', 
                bind: '{gridstore}', 
                columns: [ 
                        //... 
                ] 
        }] 

        //... 
}); 

Model's data is fetch through a Proxy:

Model:

Ext.define("App.model.gridView", { extend: 'Ext.data.Model',

schema: { 
    namespace: 'App.model' 
}, 

proxy: { 
    //proxy remote api stuff...... 
}. 

idProperty: 'id'. 
primaryKeys: 'id'. 
fields: [ 
    //fields 
] 

});

I have no idea what an anonymous model is and I haven't found anything related in the web, any ideas?

Thanks in advance!

1

1 Answers

0
votes

The reason seems to be that in my Server's response I have a JSON Object called "metaData", which collides with the one available in JSON Reader:

Response MetaData

The server can return metadata in its response, in addition to the record data, that describe attributes of the data set itself or are used to reconfigure the Reader. To pass metadata in the response you simply add a metaData attribute to the root of the response data. The metaData attribute can contain anything, but supports a specific set of properties that are handled by the Reader if they are present:

http://docs.sencha.com/extjs/5.0/apidocs/#!/api/Ext.data.reader.Json

The curious thing is that I don't use any of the available metaData options for JSON Reader, nothing related to any anonymous model, therefore this might be considered a bug