1
votes

I have a ExtJS grid with a store mapped to it.

The JSON response for the store contains 20 fields, but I have mapped only 10 fields in the store. Is it possible for me to obtain the other 10 fields without me having to map them in the store or is it necessary for me to map all the fields to the store. Doing this on row select event of the grid. As for the code, I am able to create the grid, map the store, fire the event and even get the record for the selected row with the mapped 10 field.

Any suggestions ??

As requested by Shekhar :

Store definition

Ext.define('gdoc.store.PrintPaperStore', {
    extend: 'Ext.data.Store',

    constructor: function(cfg) {
        var me = this;
        cfg = cfg || {};
        me.callParent([Ext.apply({
            autoLoad: true,
            storeId: 'PrintPaperStore',
            proxy: {
                type: 'ajax',
                url: 'urlToRetrieveTheJSON',
                reader: {
                    type: 'json',
                    root: 'root'
                }
            },
            fields: [{
                    mapping: 'value',
                    name: 'value'
                },
                {
                    mapping: 'display',
                    name: 'display'
                }
            ]
        }, cfg)]);
    }
});

The JSON Response :

{
     "root": [{
         "value": "COATED115",
         "display": "Coated recycled paper (115gms)",
         "description": "Good quality",
         "extra": "EXTRA INFO"
     }, {
         "value": "COATED135",
         "display": "Coated recycled paper (135gms)",
         "description": "Good quality"
     }, {
         "value": "OFFSET",
         "display": "Offset recycled paper (80gms)",
         "description": "Good quality",
         "extra": "EXTRA INFO"
     }, {
         "value": "OTHER",
         "display": "Other paper (client to order)",
         "description": "Good quality",
         "extra": "EXTRA INFO"
     }]
 }

As you can see I have mapped only value and display from the JSON response in the store.

Is it possible for me to retrieve values of description and extra without me having to map them in the store.

2
Can you show ur store's code?Shekhar
Please include your code in your question so we can help you better.joelparkerhenderson

2 Answers

1
votes

You can access the .raw property on the model, which will contain the raw JSON from the reader.

1
votes

No. The model, or store, must set all the fields you want to have available from the JSON data.

I'm confused as to why you don't want to map the extra fields? It's it purely time saving and hoping there was a quicker way to get access to the data? Or are you expecting the fields names to be dynamic?

If it's the dynamic reason, take a look at this post for a solution. Dynamic model with ExtJS 4