ObjectDataField

This field class handles fields that hold an object.

class Person extends Model {
    static fields = [
        'name',
        { name : 'address', type : 'object' }
    ];
}

For the field to count as modified, the whole object has to be replaced:

person.address = { ...address };

Or, sub properties of the object has to be modified using calls to set():

person.set('address.street', 'Main Street');

Note that if any property of the nested object requires conversion after load, you have to define that property as a field:

class Order extends Model {
    static fields = [
        'title',
        { name : 'details', type : 'object' },
        { name : 'details.date', type : 'date' }
    ];
}

const order = new Order({
   title   : 'Order 1',
   details : {
     customer : 'Bill',
     // Definition above required for this to be converted to a date
     date     : '2020-01-01'
   }
});

Configs

18
alwaysWriteDataField
calculateDataField
columnDataField
compareDataField
dataSourceDataField
defaultValueDataField
descriptionDataField
internalDataField
labelDataField
nameDataField
nullableDataField
nullTextDataField
nullValueDataField
persistDataField
readOnlyDataField

Properties

7

Class hierarchy

isObjectDataField: Boolean= truereadonly
Identifies an object as an instance of ObjectDataField class, or subclass thereof.
isObjectDataField: Boolean= truereadonlystatic
Identifies an object as an instance of ObjectDataField class, or subclass thereof.
isDataFieldDataField

Lifecycle

configBase

Functions

19

Configuration

applyDefaultsstaticBase

Events

Lifecycle

destroystaticBase

Misc

initClassstaticBase
isOfTypeNamestaticBase
mixinstaticBase

Other

convertDataField
isEqualDataField
printDataField
printValueDataField
serializeDataField