Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extjs 4.0 store - how to find fields in the store (or model)

In Ext 3.x I could get an array of field names with this:

mystore.fields.keys

How can I do this in 4.0? I can't even see how I can get the model that the store is using (no 'getModel' method). Do I need to find a record and get the fields that way? I define the store with :

Ext.define('AM.store.Equipments', {
    extend: 'Ext.data.Store',
    model: 'AM.model.Equipment',

    mycustFunc: function () {
            var myfields = this.fields.keys  (fails!)

EDIT: Thanks... looking in firebug more it seems like this gets what I want:

this.model.prototype.fields.keys
like image 933
amackay11 Avatar asked Sep 16 '11 14:09

amackay11


1 Answers

While there isn't a getModel() method for the Store itself, the Proxy holds the Model, so you can simply use store.getProxy().getModel() to fetch the Model, and thereby the Model's fields. For replicating a Store, just use model: originalStore.getProxy().getModel().modelName.

like image 173
nscrob Avatar answered Oct 02 '22 23:10

nscrob