AttributesView
The AttributesView control is used to represent single record field values in UI. Can be used as a single or multiple values editor. The control automatically adjusts to underlying data and displays the required editor (TextBox, DateTime Picker, Combobox, CheckBox, etc).
The AttributesView
inherits all the methods and properties from the base class View
.
Constructor:
constructor(parent: View)
Creates an instance of AttributesView control.parent
: the View containing the control itself.
Properties:
source: Record | Attributes | Attribute[] | RecordsView
Data needed to initialize AttributesView. It can be a Record object, a collection/array of Attribute objects. You can initialize the source property with RecordsView control (it will display the currently focused record in the RecordsView).-
fields: string[] | field[] | Attribute[]
An array of fields that will be displayed in the view. These can be field names, field objects, or Attribute objects.
// simple attrsView.fields = [Contract.party, Contract.amount] // with Attribute objects attrsView.fields = [ new Attribute({ label: Contract.amount.fieldLabel, // could use a simple text too type: AttributeValueType.String, // type String is default (can be omitted) value: (a)=> a.amount + ' $', // use getter to format display setValue: (a, v) => { // use setter to process value Record.amount = do some calc with v; }, foreground: (a)=> { if (a.amount > 1000) return 'red'; }, font: { style: { bold: true, underline: true } } }), new Attribute({ name: Contract.party, }), ]
-
focused: Attribute | Field | string
Indicates the record field or attribute that is currently focused within the control. valueAlignment: Alignment
Specifies the alignment of values in the control.options: AttributesViewOptions
Provides options for configuring the behavior of the AttributesView. See AttributesViewOptions.layout: Attributes | Attribute[]
Defines how record fields will be displayed in the control. When initializing source property with a Record object, AttributesView will automatically retrieve layout defined in the record’s data class (if any). If you have layout defined on data class, you can use layout property to override it.
Methods:
-
expand(): void
Expands the focused field or attribute to show all the sub-fields or sub-attributes (if any). -
collapse(): void
Collapses the focused field or attribute. -
changing(handler: (recOrAttr, name, value) => any)
Registers a handler that is triggered before a record or attribute is changed. -
change(handler: (recOrAttr, name, value) => any)
Registers a handler that is triggered when a record or attribute is changed. -
buttonClick(handler: (recOrAttr, name) => any): any
Registers a handler that is triggered when AttributeButton is clicked within the control. -
lastRowEnter(handler: (recOrAttr) => boolean)
A function that is called when the "Enter" key is pressed on the last field/attribute in the control. If the handler returns true, the first field/attribute will be automatically focused.