Add DevExtreme to an ASP.NET Core Angular Application
This article describes how to create an ASP.NET Core Angular application and add a DevExtreme widget to it. Before you begin, make sure that you have Visual Studio 2017 or higher and .NET Core 2.0 SDK installed.
Open Visual Studio 2017 and create a new ASP.NET Core Angular application using the ASP.NET Core Web Application template.
Open the package.json file and add the devextreme and devextreme-angular packages to the
devDependencies
section."devDependencies": { ... "devextreme": "17.2.18", "devextreme-angular": "17.2.18" }
Save the changes and wait until Visual Studio has downloaded the dependencies.
Open the webpack.config.vendor.js file, register the required .css files and then build the application to update the vendor bundle.
const nonTreeShakableModules = [ ... 'devextreme/dist/css/dx.common.css', 'devextreme/dist/css/dx.light.css' ];
Open the ClientApp\app\app.shared.module.ts file and import individual DevExtreme modules or the entire DevExtreme. Add the imported modules to the
imports
array:// Imports the entire DevExtreme import { DevExtremeModule } from 'devextreme-angular'; // Imports a separate module // import { DxDataGridModule } from 'devextreme-angular'; @NgModule({ ... imports: [ ... DevExtremeModule, // DxDataGridModule, ... ] })
Open the Views\Home\Index.cshtml file and remove the
asp-prerender-module
attribute from the<app>
element. This disables server-side rendering, which is currently not supported by DevExtreme.Open the ClientApp\app\components\fetchdata\fetchdata.component.html file and replace the table in it with the following code, which creates the DevExtreme DataGrid widget and binds it to sample data already provided by the
FetchDataComponent
:<dx-data-grid [dataSource]="forecasts"></dx-data-grid>
Run the application and when it has been loaded, navigate to the Fetch data page to view the DataGrid.
Refer to the DevExtreme-Angular repository on GitHub for more information on working with DevExtreme controls in Angular.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
We appreciate your feedback.