DevExtreme Angular - Using Ionic
Install DevExtreme
Install the devextreme
and devextreme-angular
npm packages:
npm install devextreme@25.2 devextreme-angular@25.2 --save --save-exact
Import Stylesheets
Open the global.scss
file in the src
folder and import a predefined theme stylesheet (dx.light.css
in the code below).
@import '~devextreme/dist/css/dx.light.css';
Import DevExtreme Modules
DevExtreme components are standalone. Import them as follows:
import { Component } from '@angular/core'; import { DxButtonComponent } from 'devextreme-angular/ui/button'; @Component({ selector: 'app-root', standalone: true, imports: [DxButtonComponent], templateUrl: './app.component.html', styleUrl: './app.component.css' }) export class AppComponent { }
The nested components should also be imported. For example, the following code snippet imports DataGrid, its columns, sorting, and a template.
*dxTemplate
, import DxTemplateDirective
.import { Component } from '@angular/core'; import { DxTemplateDirective } from 'devextreme-angular'; import { DxDataGridComponent, DxiDataGridColumnComponent } from 'devextreme-angular/ui/data-grid'; @Component({ selector: 'app-root', standalone: true, imports: [DxDataGridComponent, DxiDataGridColumnComponent, DxTemplateDirective], templateUrl: './app.component.html', styleUrl: './app.component.css' }) export class AppComponent { }
<dx-data-grid> <dxo-data-grid-sorting mode="none"></dxo-data-grid-sorting> <dxi-data-grid-column dataField="date"></dxi-data-grid-column> <dxi-data-grid-column caption="Employee" cellTemplate="employeeTemplate" ></dxi-data-grid-column> <div *dxTemplate="let data of 'employeeTemplate'"> <img [src]="data.value" alt="Picture of {{ data.data.FirstName }} {{ data.data.LastName }}" /> </div> </dx-data-grid>
Modules facilitate working with multiple configuration components. You can import them as follows:
import { Component } from '@angular/core'; import { DxDataGridModule } from 'devextreme-angular'; @Component({ selector: 'app-root', standalone: true, imports: [DxDataGridModule], templateUrl: './app.component.html', styleUrl: './app.component.css' }) export class AppComponent { }
If you use NgModule
, import the DevExtreme modules as demonstrated in the following code snippet. If tree shaking is configured in your application, import the modules from devextreme-angular
. If not, import them from files.
// ... import { DxButtonModule } from 'devextreme-angular'; // or if tree shaking is not configured // import { DxButtonModule } from 'devextreme-angular/ui/button'; @NgModule({ imports: [ // ... DxButtonModule ], // ... }) export class AppModule { }
Now you can use the DevExtreme UI component in your application:
<dx-button text="Click me" (onClick)="helloWorld()"> </dx-button>
// ... export class AppComponent { helloWorld() { alert('Hello world!'); } }
Register 3rd-Party Dependencies
The DataGrid UI component and Globalize localization require additional libraries. Follow the instructions from the Register 3rd-Party Dependencies article for Angular.
Run the Application
Run the application with the following command:
ionic serve
Open http://localhost:8100/ to browse the application.
If you have technical questions, please create a support ticket in the DevExpress Support Center.