|
| 1 | +# ASP.NET Core DevExtreme Example |
| 2 | + |
| 3 | +## Installation |
| 4 | + |
| 5 | +Download the example and use Visual Studio 2022 (or later) or Visual Studio Code to open the project. This project targets .NET 8.0. |
| 6 | + |
| 7 | +## Client-side resources and bundling |
| 8 | + |
| 9 | +This project uses [NPM](https://www.npmjs.com/) and [Gulp.js](https://gulpjs.com/) to install client-side libraries. The project restores NPM packages before the first build. Then, Gulp bundles required scripts and CSS files into the resulting package during the first and every next build. |
| 10 | + |
| 11 | +The project includes: |
| 12 | +- DevExtreme 24.2.3 |
| 13 | +- DevExtreme.AspNet.Core 24.2.* |
| 14 | +- DevExtreme.AspNet.Data 5.* |
| 15 | +- jQuery 3.7.1 |
| 16 | +- Bootstrap 5.3.3 |
| 17 | + |
| 18 | +The resulted bundles will be located in the `wwwroot` folder: |
| 19 | +* `css/vendor.css` - a file with all CSS styles. |
| 20 | +* `css/icons` and `css/fonts` - folders that contain fonts and icons for DevExtreme themes. |
| 21 | +* `js/vendor.js` - a file that contains all scripts. |
| 22 | + |
| 23 | +The default bundle includes jQuery, Bootstrap, and DevExtreme. |
| 24 | + |
| 25 | +### Add more 3rd-party libraries for additional features/components |
| 26 | + |
| 27 | +The main logic is located in the the `gulpfile.js` file at the root application level. The file contains two tasks: |
| 28 | + |
| 29 | +* the `add-resources` task |
| 30 | + |
| 31 | + * copies JavaScript files located in the `scripts` array and adds them to `vendor.js`. The script bundle is moved to `wwwroot\js`. |
| 32 | + * copies CSS styles located in the `styles` array and merges them into the `vendor.css` bundle. Then, this bundle is moved to `wwwroot\css` |
| 33 | + * copies DevExtreme `fonts` and `icons` folders from NPM to `wwwroot\css` |
| 34 | + |
| 35 | +* the `clean` task removes all previously created files (`vendor.js` and `vendor.css`) and folders (`icons` and `fonts`) |
| 36 | + |
| 37 | +If you need to include more features, you can uncomment one of the following sections: |
| 38 | + |
| 39 | +* Gantt - scripts and styles for [dxGantt](https://js.devexpress.com/DevExtreme/Guide/UI_Components/Gantt/Getting_Started_with_Gantt/). |
| 40 | +* Diagram - scripts and styles for [dxDiagram](https://js.devexpress.com/DevExtreme/Guide/UI_Components/Diagram/Getting_Started_with_Diagram/). |
| 41 | +* Export - scripts and styles for the exporting feature: [Export Data to Excel](https://js.devexpress.com/DevExtreme/Guide/UI_Components/DataGrid/Getting_Started_with_DataGrid/#Export_Data). |
| 42 | +* HtmlEditor - scripts and styles for [dxHtmlEditor](https://js.devexpress.com/DevExtreme/Guide/UI_Components/HtmlEditor/Overview/). |
| 43 | +* Full Bundle - scripts and styles for all above mentioned features/components. |
| 44 | + |
| 45 | +## Code |
| 46 | + |
| 47 | +Take a look at the following files of this example to see the required code: |
| 48 | + |
| 49 | +**Controllers:** |
| 50 | +- `Controllers/HomeController.cs` - Main controller with Index action |
| 51 | +- `Controllers/SampleDataController.cs` - API controller for sample data |
| 52 | + |
| 53 | +**Models:** |
| 54 | +- `Models/SampleData.cs` - Sample data model |
| 55 | +- `Models/SampleOrder.cs` - Sample order model |
| 56 | + |
| 57 | +**Views:** |
| 58 | +- `Views/Home/Index.cshtml` - Main page with DevExtreme components |
| 59 | +- `Views/Shared/_Layout.cshtml` - Layout template |
| 60 | +- `Views/_ViewImports.cshtml` - Global imports |
| 61 | +- `Views/_ViewStart.cshtml` - View start configuration |
| 62 | + |
| 63 | +**Configuration:** |
| 64 | +- `Program.cs` - Application entry point |
| 65 | +- `Startup.cs` - Service configuration |
| 66 | +- `gulpfile.js` - Build automation |
| 67 | +- `package.json` - NPM dependencies |
| 68 | +- `ASP.NET Core.csproj` - Project file |
| 69 | + |
| 70 | +## Development server |
| 71 | + |
| 72 | +Use the Visual Studio `Run (F5)` command or `dotnet run` command to run the project. The application will be available at `https://localhost:5001` (HTTPS) or `http://localhost:5000` (HTTP). |
| 73 | + |
| 74 | +## Further help |
| 75 | + |
| 76 | +You can learn more about the ASP.NET Core components' syntax in our documentation: [Concepts](https://docs.devexpress.com/AspNetCore/400574/devextreme-based-controls/concepts/razor-syntax) |
| 77 | +The client-side API is based on jQuery [jQuery documentation](https://api.jquery.com/) and described in the following topics: |
| 78 | +* [Get and Set Properties](https://js.devexpress.com/DevExtreme/Guide/jQuery_Components/Component_Configuration_Syntax/#Get_and_Set_Properties) |
| 79 | +* [Call Methods](https://js.devexpress.com/DevExtreme/Guide/jQuery_Components/Component_Configuration_Syntax/#Call_Methods) |
| 80 | +* [Get a UI Component Instance](https://js.devexpress.com/DevExtreme/Guide/jQuery_Components/Component_Configuration_Syntax/#Get_a_UI_Component_Instance) |
| 81 | + |
| 82 | +To get more help on DevExtreme submit an issue in the [Support Center](https://supportcenter.devexpress.com/ticket/create) |
| 83 | + |
| 84 | + |
0 commit comments