2 |
Installation
3 |
4 |
This grid system uses most of the latest features of Angular Material and the CDK project like Drag and Drop
5 | and also CDK Virtual Scrolling. If you intend to use this component make sure you have Angular Material Version and
6 | CDK version of 10.2.7 or higher.
7 |
8 |
1. Install Angular Material
9 |
10 |
11 |
2. Install Angular Material Data Grid
12 |
13 |
Note: For Angular 15 please add the legacy theme imports. Refer to this Style file for your reference.
14 |
15 |
16 |
3. Import Modules
17 |
18 |
19 |
4. Usage (Basic)
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/src/app/pages/installation/installation.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dillyboy/angular_material_data_grid/f94fbe28c93bcd61dd42f175036acf664541afaf/src/app/pages/installation/installation.component.scss
--------------------------------------------------------------------------------
/src/app/pages/installation/installation.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-installation',
5 | templateUrl: './installation.component.html',
6 | styleUrls: ['./installation.component.scss']
7 | })
8 | export class InstallationComponent implements OnInit {
9 |
10 | angularMaterial = `ng add @angular/material`;
11 | npmInstall = `// The version you install depends on the verison of Angular Material you are using
12 |
13 | // Between Angular Material verison 10.2.7 and 13.3.9
14 | npm i angular-material-data-grid@0.6.1
15 | // Between Angular Material verison 14.0.0 and 14.2.5
16 | npm i angular-material-data-grid@0.8.0
17 | // Angular Material verison 15.0.0 and above
18 | npm i angular-material-data-grid`;
19 | modules = `
20 | import { AngularMaterialDataGridModule } from 'angular-material-data-grid';
21 |
22 | imports: [
23 | ...
24 | AngularMaterialDataGridModule
25 | ]`;
26 |
27 | usage = {
28 | html: `
29 |
30 |
31 |
2 |
Introduction
3 |
4 |
The initial purpose of creating this data grid was to make it easy for developers to easily create highly advanced
5 | data grids with server-side pagination along with multiple filters and sorting with minimum effort and time.
6 | (Client Side Pagination is also present.)
7 | In order to make this possible a tight integration between the back-end data-source and the front-end component
8 | should be agreed upon. This gives the ability to stay focused on advanced functionality and the creation of data
9 | grids with only configurations while staying opinionated. Moreover, the solutions provided by reputed vendors were
10 | expensive which makes open-source software more attractive to many clients. This product is 100% open source.
11 |
12 |
Grid Request
13 |
The grid system should be given a URL which contains a POST endpoint that will accept a request which looks like the
14 | object shown below.
(Go to the demo page and analyze the network tab to understand this better.)
15 |
* entity is an optional attribute which the developer can configure to send additional information to the backend.
16 |
* All other request parameters are automatically handled by the grid system.
17 |
18 |
19 |
Grid Response
20 |
The grid response should contain a boolean value to determine if the request is a success or failure and more
21 | importantly the payload section should contain the requested amount of rows and also the total number of rows
22 | which is present in the database. Note that the total number of rows is not needed for client side paginated grids
23 | but it is essential for server side pagination.
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/src/app/pages/introduction/introduction.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dillyboy/angular_material_data_grid/f94fbe28c93bcd61dd42f175036acf664541afaf/src/app/pages/introduction/introduction.component.scss
--------------------------------------------------------------------------------
/src/app/pages/introduction/introduction.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-introduction',
5 | templateUrl: './introduction.component.html',
6 | styleUrls: ['./introduction.component.scss']
7 | })
8 | export class IntroductionComponent implements OnInit {
9 |
10 | gridRequestObj = `{
11 | "entity": {}, // any data that can be sent from outside the grid component
12 | "filters": [], // filters array generated by the grid
13 | "page": 1, // page no
14 | "perPage": 100, // page size
15 | "sort": null, // sort -> asc/desc/null
16 | "sortField": null // field name to sort data
17 | }`;
18 |
19 | gridResponseObj = `{
20 | "payload": {
21 | "gridData": [...], // grid data
22 | "totalCount": 1000, // total count of records in the database for pagination purposes
23 | "other": null // send any other data you wish here in order to use in your application, Refer to @Output() responseEmit: EventEmitter