-
AI-powered Extensions
-
Data Grid
-
Tree List
-
Chat
-
HTML Editor
-
Form
-
-
Data Grids / Data Management
-
Data Grid
- Overview
-
Data Binding
-
Filtering
- Sorting
-
Editing
-
Grouping
-
Selection
- Focused Row
- Paging
-
Scrolling
-
Columns
- AI Assistant
-
Master-Detail
-
Data Summaries
-
Drag & Drop
-
Export to PDF
-
Export to Excel
- Appearance
-
Customization
- State Persistence
-
Adaptability
-
Keyboard Navigation
- Right-To-Left Support
-
Tree List
- Overview
-
Data Binding
-
Filtering
- Sorting
-
Editing
-
Selection
- Focused Row
- Paging
-
Columns
- Drag & Drop
- State Persistence
- Adaptability
-
Keyboard Navigation
-
Card View
-
Pivot Grid
- Overview
-
Data Binding
-
Field Management
-
Data Summaries
- Drill Down
- Filtering
-
Scrolling
-
Export to Excel
- Chart Integration
- Customization
- State Persistence
-
Filter Builder
-
-
Data Visualization
-
Charts
- Overview
-
Data Binding
-
Common Concepts
-
Axis
-
Aggregation
-
Tooltips
-
Selection
-
Customization
-
Zooming
-
Export
-
-
Area Charts
-
Bar Charts
- Bullet Charts
-
Doughnut Charts
-
Financial Charts
-
Funnel and Pyramid Charts
-
Line Charts
- Pareto Chart
-
Pie Charts
-
Point Charts
-
Polar and Radar Charts
-
Range Charts
- Sankey Chart
-
Sparkline Charts
-
Tree Map
-
Gauges
- Overview
-
Runtime update
-
Bar Gauge
-
Circular Gauge
-
Linear Gauge
-
Diagram
- Overview
-
Data Binding
-
Featured Shapes
-
Custom Shapes
-
Document Capabilities
-
User Interaction
- UI Customization
- Adaptability
-
-
Scheduling / Planning
-
Scheduler
- Overview
-
Data Binding
-
Views
-
Appointments
-
Timetable
- Editing
-
Grouping
- Virtual Scrolling
- Drag & Drop
-
Customization
- Adaptability
-
Gantt
- Overview
- Data Binding
-
Filtering
- Sorting
- Strip Lines
- Export to PDF
- Validation
-
Customization
-
-
Messaging
-
WYSIWYG Editor
-
Forms
-
Data Editors
- Overview
-
Common Concepts
-
Calendar
- Check Box
- Color Box
-
Date Box
-
Date Range Box
-
Number Box
- Radio Group
-
Range Selector
- Range Slider
- Slider
- Switch
- Text Area
- Text Box
-
Drop-Downs
- Autocomplete
-
Drop Down Box
-
Select Box
-
Tag Box
-
Lookup
-
Buttons
-
File Upload / File Management
-
File Manager
- Overview
-
File System Types
-
Customization
-
File Uploader
-
-
Popup and Notifications
-
Navigation
- Overview
- Accordion
-
Action Sheet
-
Context Menu
-
Menu
- Multi View
-
Drawer
-
Tab Panel
-
Tabs
-
Toolbar
-
Stepper
- Pagination
-
List
-
Tree View
- Right-to-Left Support
-
Layout
-
Tile View
- Splitter
-
Gallery
- Scroll View
- Box
- Responsive Box
-
-
Interactive Wrappers
-
Sortable
- Resizable
-
-
Progress Indicators
-
Maps
- Overview
-
Map
-
Vector Map
-
Data Binding
- Multiple Layers
-
Markers
- Legend
-
Zooming and Panning
-
Customization
-
-
Localization
Related Demos:
Your search did not match any results.
Angular Form - Customize Fields at Runtime
The Form component allows you to add/remove items and specify item visibility at runtime. The Form only updates the affected items and does not re-render the entire form.
In this demo, the "Show Address" checkbox specifies the visibility of address-related fields. Review the component's code to see how to set the "HomeAddress" group's visible attribute.
Click the "Add phone" button to add a new phone editor. This action adds a new item to the items array of the "phones" group. Each phone editor contains a button that deletes it from the items array and the Form.
Backend API
<div class="long-title">
<h3>Personal details</h3>
</div>
<div id="form-container">
<dx-form id="form" [colCount]="2" [formData]="employee">
<dxi-form-item itemType="group">
<dxi-form-item itemType="group" caption="Personal Data">
<dxi-form-item dataField="FirstName"></dxi-form-item>
<dxi-form-item dataField="LastName"></dxi-form-item>
<dxi-form-item
editorType="dxCheckBox"
[editorOptions]="checkBoxOptions"
></dxi-form-item>
</dxi-form-item>
<dxi-form-item itemType="group">
<dxi-form-item
itemType="group"
caption="Home Address"
name="HomeAddress"
[visible]="isHomeAddressVisible"
>
<dxi-form-item dataField="Address"></dxi-form-item>
<dxi-form-item dataField="City"></dxi-form-item>
</dxi-form-item>
</dxi-form-item>
</dxi-form-item>
<dxi-form-item itemType="group" caption="Phones" name="phones-container">
@for (phone of phoneOptions; track $index) {
<dxi-form-item itemType="group" name="phones">
<dxi-form-item
[dataField]="'Phones[' + $index + ']'"
[editorOptions]="phoneOptions[$index]"
>
<dxo-form-label [text]="'Phone ' + ($index + 1)"> </dxo-form-label>
</dxi-form-item>
</dxi-form-item>
}
<dxi-form-item
itemType="button"
horizontalAlignment="left"
cssClass="add-phone-button"
[buttonOptions]="addPhoneButtonOptions"
>
</dxi-form-item>
</dxi-form-item>
</dx-form>
</div>
import { bootstrapApplication } from '@angular/platform-browser';
import {
ChangeDetectorRef, Component, enableProdMode, provideZoneChangeDetection,
} from '@angular/core';
import { DxFormModule } from 'devextreme-angular';
import { DxCheckBoxTypes } from 'devextreme-angular/ui/check-box';
import { DxButtonTypes } from 'devextreme-angular/ui/button';
import { DxTextBoxTypes } from 'devextreme-angular/ui/text-box';
import { Employee, Service } from './app.service';
if (!/localhost/.test(document.location.host)) {
enableProdMode();
}
@Component({
selector: 'demo-app',
providers: [Service],
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
imports: [
DxFormModule,
],
})
export class AppComponent {
employee: Employee;
isHomeAddressVisible = true;
phoneOptions: DxTextBoxTypes.Properties[] = [];
checkBoxOptions: DxCheckBoxTypes.Properties = {
text: 'Show Address',
value: true,
onValueChanged: (e: DxCheckBoxTypes.ValueChangedEvent) => {
this.isHomeAddressVisible = e.component.option('value');
this.changeDetectorRef.detectChanges();
},
};
addPhoneButtonOptions: DxButtonTypes.Properties = {
icon: 'add',
text: 'Add phone',
onClick: () => {
this.employee.Phones.push('');
this.phoneOptions = this.getPhonesOptions(this.employee.Phones);
this.changeDetectorRef.detectChanges();
},
};
constructor(service: Service, private changeDetectorRef: ChangeDetectorRef) {
this.employee = service.getEmployee();
this.phoneOptions = this.getPhonesOptions(this.employee.Phones);
}
getPhonesOptions = (phones: string[]) => phones.map((_, index) => this.generateNewPhoneOptions(index));
generateNewPhoneOptions(index: number): DxTextBoxTypes.Properties {
return {
mask: '(X00) 000-0000',
maskRules: { X: /[01-9]/ },
buttons: [{
name: 'trash',
location: 'after',
options: {
stylingMode: 'text',
icon: 'trash',
onClick: () => {
this.employee.Phones.splice(index, 1);
this.phoneOptions = this.getPhonesOptions(this.employee.Phones);
this.changeDetectorRef.detectChanges();
},
},
}],
};
}
}
bootstrapApplication(AppComponent, {
providers: [
provideZoneChangeDetection({ eventCoalescing: true, runCoalescing: true }),
],
});
::ng-deep #form-container {
margin: 10px 10px 30px;
}
::ng-deep .long-title h3 {
font-family: 'Segoe UI Light', 'Helvetica Neue Light', 'Segoe UI', 'Helvetica Neue', 'Trebuchet MS', Verdana;
font-weight: 200;
font-size: 28px;
text-align: center;
margin-bottom: 20px;
}
::ng-deep .add-phone-button {
margin-top: 10px;
}
import { Injectable } from '@angular/core';
export class Employee {
FirstName: string;
LastName: string;
Address: string;
City: string;
Phones: string[];
}
const employee: Employee = {
FirstName: 'John',
LastName: 'Heart',
Address: '351 S Hill St., Los Angeles, CA',
City: 'Atlanta',
Phones: ['8005552797', '8005953232'],
};
@Injectable()
export class Service {
getEmployee(): Employee {
return employee;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>DevExtreme Demo</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0" />
<link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/26.1.5/css/dx.light.css" />
</head>
<body class="dx-viewport">
<div class="demo-container">
<demo-app>Loading...</demo-app>
</div>
<script src="https://cdn.jsdelivr.net/npm/zone.js@0.16.2/bundles/zone.umd.js"></script>
<script src="./bundle.js" type="module"></script>
</body>
</html>