The 'MetaRow' class represents each row of the data table and manages the events associated with the data. This class handles tasks such as adding, modifying, or deleting data and informs you of changes through events.

Hierarchy (view full)

Constructors

  • Creates a 'MetaRow' object.

    Parameters

    • entity: BaseEntity

      This is the 'BaseEntity' object to which 'MetaRow' belongs.

    Returns MetaRow

    const row = new MetaRow(entity);
    

Properties

_entity: BaseEntity

Returns the entity to which this 'MetaRow' belongs.

The object 'BaseEntity' that owns this row.

_guid: string

Unique identifier of the object (GUID). Uniquely identifies the object.

_list: any[]

Returns a list of elements in a row.

An array of elements.

_type: Function

The generator function of the object. The function used when the object was created.

$keys: string[]

Returns the element key in the row.

The key arrangement of the element.

count: number

Returns the number of elements in the row.

The total number of elements.

_NS: string

Indicates the namespace.

'Meta'
_PARAM: []

List of parameters used for the constructor.

_UNION: []

List of implemented interfaces.

[IObject, IMarshal]

Methods

  • Processes events after element changes.

    Parameters

    • idx: number

      Index where the change occurred.

    • nVal: any

      This is a newly changed value.

    • oVal: any

      This is the previous value.

    Returns void

    MetaRow#onChanged

  • Processes events before element changes.

    Parameters

    • idx: number

      Index where the change occurred.

    • nVal: any
    • oVal: any

      Existing value.

    Returns void

    MetaRow#onChanging

  • Create a new object by replicating the current 'MetaRow' object.

    Parameters

    • Optionalentity: BaseEntity

      'BaseEntity' of the target to be replicated. (Optional)

    Returns this

    Replicated 'MetaRow' object.

    const clone = row.clone(entity);
    
  • Compare the current object with the specified object.

    Parameters

    • target: object

      the object to be compared to.

    Returns boolean

    Returns whether the two objects are the same.

  • Converts the current 'MetaRow' object to a serialized GUID type object. In the serialization process, the cyclic reference is replaced by the value '$ref'.

    Parameters

    • OptionalvOpt: number

      Specifies the serialization option.

      • '0': Convert to a reference structure (including '_guid' and '$ref')
      • '1': Converting to a redundant structure (including '_guid' and '$ref')
      • '2': Conversion to non-coordinated structure (excluding '_guid' and '$ref')
    • Optionalowned: object | object[]

      The parent objects that currently own the object. You can receive an object or array of objects.

    Returns object

    Serialized object.

    const serialized = row.getObject(2); // import serialized objects in a non-coordinated structure
    
  • Returns the creators of the current object and all the creators of the prototype chain to the array.

    Returns Function[]

    Returns the array of generator functions.

    const types = obj.getTypes();
    console.log(types); // [Function: MetaObject]
  • Verify that the current object is an instance of the specified type (including _UNION)

    Parameters

    • target: string | object

      The type of object to be checked (object or string).

    Returns boolean

    Returns whether it is an instance of the specified type.

  • Sets the serialized GUID type object to the current 'MetaRow' object. During this process, the object is initialized.

    Parameters

    • oGuid: object

      object of serialized GUID type.

    • Optionalorigin: object

      This is the original object that sets the current object. Default is 'oGuid'.

    Returns void

    row.setObject(serializedObject); // set serialized objects in current row
    

Events

onChanged: ((idx: number, nVal: any, oVal: any, _this: this) => void)

Event after element change.

MetaRow#onChanged

Type declaration

    • (idx, nVal, oVal, _this): void
    • Parameters

      • idx: number

        Index where the change occurred.

      • nVal: any

        This is a newly changed value.

      • oVal: any

        This is the previous value.

      • _this: this

        The object that caused the event.

      Returns void

row.onChanged = (idx, nVal, oVal, _this) => { console.log('Value has changed'); };
onChanging: ((idx: number, nVal: any, oVal: any, _this: this) => void)

Event before element change.

MetaRow#onChanging

Type declaration

    • (idx, nVal, oVal, _this): void
    • Parameters

      • idx: number

        Index where the change occurred.

      • nVal: any

        This is the new value to be changed.

      • oVal: any

        Existing value.

      • _this: this

        The object that caused the event.

      Returns void

row.onChanging = (idx, nVal, oVal, _this) => { console.log('Value is about to change'); };