Object
$comp
$comp is an object for dynamically defining components from an action.
This feature was added in v4.1.0.
You can dynamically define components from an action using the following syntax:
new $comp.{ComponentType}(property object: prop);The component types that can be defined are as follows:
| Component | Component Type | Required Properties | Notes |
|---|---|---|---|
| Text Field | TextField | 1. id 2. x 3. y | |
| Text Area | TextArea | 1. id 2. x 3. y | |
| Number Field | NumberField | 1. id 2. x 3. y | |
| Big Number | BigNumber | 1. id 2. x 3. y | |
| Search Field | SearchField | 1. id 2. x 3. y | |
| Password | Password | 1. id 2. x 3. y | |
| Select | Select | 1. id 2. x 3. y | |
| Combobox | Combobox | 1. id 2. x 3. y | |
| Radio Button | RadioButton | 1. id 2. x 3. y | |
| Radio Group | RadioGroup | 1. id 2. x 3. y | |
| Checkbox | Checkbox | 1. id 2. x 3. y | |
| Checkbox Group | CheckboxGroup | 1. id 2. x 3. y | |
| Switch | Switch | 1. id 2. x 3. y | |
| Rating | Rating | 1. id 2. x 3. y | |
| Slider | Slider | 1. id 2. x 3. y | |
| Spreadsheet | Spreadsheet | 1. id 2. x 3. y | |
| Date Picker | DatePicker | 1. id 2. x 3. y | |
| Time Picker | TimePicker | 1. id 2. x 3. y | |
| Date Time Picker | DateTimePicker | 1. id 2. x 3. y | |
| File Upload | FileUpload | 1. id 2. x 3. y | |
| Button | Button | 1. id 2. x 3. y | |
| Icon Button | IconButton | 1. id 2. x 3. y | |
| 2D Scanner | QrScanner | 1. id 2. x 3. y | |
| Typography | Typography | 1. id 2. x 3. y | |
| Rich Text | RichText | 1. id 2. x 3. y | |
| Image | Image | 1. id 2. x 3. y | |
| Image List | ImageList | 1. id 2. x 3. y | |
| External Resource | ExternalResource | 1. id 2. x 3. y | |
| Carousel | Carousel | 1. id 2. x 3. y | |
| Avatar | Avatar | 1. id 2. x 3. y | |
| Basic List | BasicList | 1. id 2. x 3. y | |
| Detailed List | DetailedList | 1. id 2. x 3. y | |
| File View | FileView | 1. id 2. x 3. y | |
| Map | MapEmbed | 1. id 2. x 3. y | |
| App Bar | AppBar | 1. id | 1. Only one App Bar can be added to a canvas. 2. If an App Bar already exists on the canvas, an additional one cannot be created. |
| Link | Link | 1. id 2. x 3. y | |
| Breadcrumbs | Breadcrumbs | 1. id 2. x 3. y | |
| Stepper | Stepper | 1. id 2. x 3. y | |
| Bottom Navigation | BottomNavigation | 1. id | 1. Only one Bottom Navigation can be added to a canvas. 2. If a Bottom Navigation already exists on the canvas, an additional one cannot be created. |
| Tree View | TreeView | 1. id 2. x 3. y | |
| Box | Box | 1. id 2. x 3. y | |
| Divider | Divider | 1. id 2. x 3. y | |
| Line Chart | LineChart | 1. id 2. x 3. y | |
| Bar Chart | BarChart | 1. id 2. x 3. y | |
| Area Chart | AreaChart | 1. id 2. x 3. y | |
| Pie Chart | PieChart | 1. id 2. x 3. y | |
| Radar Chart | RadarChart | 1. id 2. x 3. y | |
| Event Calendar | EventCalendar | 1. id 2. x 3. y |
When dynamically defining components, only components that support the following events can execute actions when the event occurs:
- Click event
- Change event
Definition example:
const image = new $comp.Image({ id: "image_1", width: 250, height: 250, x: 50, y: 100, value: "/sample/01.png", objectFit: "contain", clickEvent: "detachedAction", detachedAction: "show_detail"})The following properties can be specified in addition to the component’s standard properties only when dynamically defining components:
| Property Name | Type | Possible Values | Description |
|---|---|---|---|
| sendOnAction | boolean | 1. true 2. false (default) | 1. If true, the detached action can access this component’s properties. 2. If false, the detached action cannot access this component’s properties. |
| zIndex | number | default: 0 | When components overlap, the one with a higher value is displayed in front. |