2

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?

Upperstage
  • 3,747
  • 8
  • 44
  • 67

1 Answers1

2

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'),
            }
        }
    ]
....
Amol Katdare
  • 6,740
  • 2
  • 33
  • 36
  • You are correct - this is exactly what I want (+1). However, my convert function is never called. I am using my store with a SuperBoxSelect - maybe that UX somehow halts the call to convert??? – Upperstage Jun 15 '11 at 16:28
  • @upper stage - post some code. technically, if the store is being loaded with records, convert should be called since this is supposed to be called at record creation time. I am not familiar with SuperBoxSelect – Amol Katdare Jun 15 '11 at 18:56