Upperstage
Upperstage

Reputation: 3757

Ext JS: Override JsonReader or post-process

A particular request to my server returns x fields of JSON. I want to combine several of these fields and insert the concatenated data into the x+1 field of my JsonStore.

I know how to process the load event, read each record, concatenate the appropriate fields, and insert into my x+1st field. However, is there a better (more efficient) way to accomplish this - perhaps by overriding JsonReader?

Upvotes: 2

Views: 930

Answers (1)

Amol Katdare
Amol Katdare

Reputation: 6760

You are looking for Ext.data.Field.convert

Reference - ExtJS 3.x / ExtJS 4.x

Example using 4.x version -


....
fields: [
        'name', 'email',
        {name: 'age', type: 'int'},
        {name: 'gender', type: 'string', defaultValue: 'Unknown'},

        {
            name: 'whatever',
            convert: function(value, record) {
                return record.get('f1') + record.get('a2'),
            }
        }
    ]
....

Upvotes: 2

Related Questions