开发者

Ext JS: Override JsonReader or post-process

开发者 https://www.devze.com 2023-03-13 04:59 出处:网络
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.

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 accom开发者_开发技巧plish this - perhaps by overriding JsonReader?


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'),
            }
        }
    ]
....
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号