The 'MetaColumn' class defines a data column and manages meta information for that column. This class provides the ability to set and process values, constraints, events, and more for a column.

Hierarchy (view full)

Constructors

  • Create 'MetaColumn' object.

    Parameters

    • name: string

      Specifies the name of the column.

    • Optionalentity: BaseEntity

      The 'BaseEntity' object to which this column belongs. (Optional)

    • Optionalproperty: object

      The object that defines the additional properties of the column. (Optional)

    Returns MetaColumn

    const column = new MetaColumn('name', entity, { required: true });
    

Properties

_entity: BaseEntity

Indicates the entity to which this column belongs. Object of type 'BaseEntity'.

_guid: string

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

_name: string

The name of the element, which acts as a unique identifier for the MetaElement.

_type: Function

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

_valueTypes: any

Defines the value type for the column. This property is used to set the value type for the column.

$alias: string

Indicates the alias for the column. The alias is used as another name for the column.

$event: EventEmitter

An event object that handles events, such as changing the column value.

$key: string

Indicates the unique key for this column.

$value: any

Limits direct access to values in a column. This property controls the setting and change of values inside.

alias: string

Sets or imports aliases for columns. Aliases are used to transfer data and set low values. Where to use (default = columnName)

  • Bind-command-ajax._execBind(): When transmitting data
  • BaseBind.setValue(row): When setting a low value to an entity
  • getValue(): Used for row
caption: string

Provides a description of the column.

columnName: string

Indicates the name of the column. Same as '_name'.

constraints: (object | Function)[]

Sets the constraints for the column. Constraints can be set in the form of objects or functions.

default: string | number | boolean

Sets the default value for the column.

getter: (() => ValueType)

Getter function of column value.

value of the column.

const value = column.getter(); // get column values
required: boolean

Sets whether a column value is required. If the value must exist, it is 'true', otherwise it is 'false'.

setter: ((value: ValueType) => void)

Setter function of column value.

Type declaration

    • (value): void
    • Parameters

      • value: ValueType

        This is the value to set.

      Returns void

column.setter ('newValue'); // set column value
value: ValueType

Gets or sets the value of the column.

  • 'getter': Returns the value if defined.
  • 'setter': Set or change the value. Get priority: 1. If there is getter, 2. Internal value $value
    set priority: 1. if there is setter, 2. if there is no setter return value
_NS: string

Indicates the namespace.

'Meta'
_PARAM: []

List of parameters used for the constructor.

['name']
_UNION: []

List of implemented interfaces.

[IElement]

Methods

  • Load the properties of the column.

    Parameters

    • property: object

      Property object to load.

    Returns void

    column._load({ required: true, constraints: [...] });
    
  • Internal method called when the value changes.

    Parameters

    • nVal: ValueType

      New value.

    • oVal: ValueType

      Existing value.

    Returns void

    MetaColumn#onChanged

  • Add constraints.

    Parameters

    • regex: RegExp

      Regular expression to apply.

    • msg: string

      Message to display when regular expression fails.

    • Optionalcode: string

      Code for failure of regular expression. (Optional)

    • Optionalcondition: boolean

      The condition that determines whether a constraint is successful/failed. Default is 'false'.

    Returns void

    column.addConstraint(/^\d+$/, 'Value must be a number');
    
  • Replicate the current column to create a new 'MetaColumn' object.

    Parameters

    • Optionalentity: BaseEntity

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

    Returns this

    Replicated 'MetaColumn' object.

    const clone = column.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 'MetaColumn' object to a serialized 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 = column.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 object to the current 'MetaColumn' 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

    column.setObject(serializedObject); // set serialized object to current column
    
  • Check that the value of the property is valid. Validates based on 'required' and 'constructions'.

    Parameters

    • value: ValueType

      This is the value to be inspected.

    Returns object

    Returns the object if it is invalid, and returns 'undefined' if it is valid.

    const validationResult = column.valid('valueToCheck');
    

Events

onChanged: ((newVal: ValueType, oldVal: ValueType, _this: this) => void)

The event that occurs when the column value changes.

MetaColumn#onChanged

Type declaration

    • (newVal, oldVal, _this): void
    • Parameters

      • newVal: ValueType

        New value.

      • oldVal: ValueType

        Previous value.

      • _this: this

        The object that caused the event.

      Returns void

column.onChanged = function(newVal, oldVal, _this) { 
console.log('Value changed');
};