Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between record.data and record.raw

Tags:

extjs

rally

I have found as I am developing extjs applications (rally applications) that sometimes the data I need from a record is in record.raw and not in record.data. What is the difference between the two, and why might this be the case?

EDIT - adding example (a column for the parent that is sortable - one of my other questions)

{text: 'Parent', dataIndex: 'Parent',
    doSort: function(state) {
        var ds = this.up('grid').getStore();
        var field = this.getSortParam();
        ds.sort({
            property: field,
            direction: state,
            sorterFn: function(v1, v2){
                if (v1.raw.Parent) {
                    v1 = v1.raw.Parent.Name;
                } else {
                    v1 = v1.data.Name;
                }

                if (v2.raw.Parent) {
                    v2 = v2.raw.Parent.Name;
                } else {
                    v2 = v2.data.Name;
                }
                return v1.localeCompare(v2);
            }
        });
    },
    renderer: function(value, meta, record) {
        var ret = record.raw.Parent;
        if (ret) {
            return ret.Name;
        } else {
            meta.tdCls = 'invisible';
            return record.data.Name;
        }
    }
},
like image 793
Tore Avatar asked Jan 12 '23 20:01

Tore


1 Answers

The data in raw is the raw data that has yet to be converted into the types specified in the fields config. Once a Reader does that conversion, the converted data is stored in data, which is typed based on the fields.

You can learn more from the docs about these here: http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.data.Model

like image 116
kevhender Avatar answered Jan 20 '23 06:01

kevhender