{"id":4899,"date":"2018-11-05T08:00:35","date_gmt":"2018-11-05T07:00:35","guid":{"rendered":"https:\/\/code-maze.com\/?p=4899"},"modified":"2021-01-20T12:52:29","modified_gmt":"2021-01-20T11:52:29","slug":"angular-material-table","status":"publish","type":"post","link":"https:\/\/code-maze.com\/angular-material-table\/","title":{"rendered":"Angular Material Table, Filtering, Sorting, Paging"},"content":{"rendered":"<p>We are going to divide this article into two major parts. The <strong>first\u00a0part<\/strong> will consist of creating environment files, HTTP repository service, and creating a new Owner module with the lazy loading feature. As you can see, everything is Angular specific, so we won\u2019t dive too deep into these sections. We already have <a href=\"https:\/\/code-maze.com\/angular-series\/\" target=\"_blank\" rel=\"noopener noreferrer\">Angular Series<\/a> in which we have talked about these topics in great detail. So if you are not familiar with these topics, we strongly recommend reading the mentioned series.<\/p>\n<p>In our source code, we can find the <code>OwnerAccountServer<\/code>\u00a0folder which contains the entire .NET Core project, which we have created in <a href=\"https:\/\/code-maze.com\/net-core-series\/\" target=\"_blank\" rel=\"noopener noreferrer\">.NET Core Series<\/a>. In the same folder, we can find the <code>_MySQL_Init_Script<\/code> folder which contains a script to create a MySQL database with its tables. Just run that script in the MySQL database and you are ready to go.<\/p>\n<p><strong>The second part<\/strong> will consist of creating a material table and populating that table with data from our server. Furthermore, we are going to create the filter, sorting, and paging functionalities for that table.<\/p>\n<p>So, it\u2019s time to start our job.<\/p>\n<ul id=\"series_parts\" style=\"display: none;\">\n<li><a href=\"https:\/\/code-maze.com\/get-started-angular-material\/\" target=\"_blank\" rel=\"noopener noreferrer\">Getting started with Angular Material<\/a><\/li>\n<li><a href=\"https:\/\/code-maze.com\/angular-material-navigation\/\" target=\"_blank\" rel=\"noopener noreferrer\">Navigation Menu &#8211; Sidebar, Main Navigation<\/a><\/li>\n<li>Angular Material Table, Filter, Sort, Paging (Current article)<\/li>\n<li><a href=\"https:\/\/code-maze.com\/angular-material-error-details-pages\/\" target=\"_blank\" rel=\"noopener noreferrer\">Angular Material Progress Bar, Spinner, CheckBox, Card, Select, Expansion Panel<\/a><\/li>\n<li><a href=\"https:\/\/code-maze.com\/angular-material-form-validation\/\" target=\"_blank\" rel=\"noopener noreferrer\">Material Inputs, DatePicker, Form Validation, Modals<\/a><\/li>\n<\/ul>\n<div class=\"wrap-collabsible\">\r\n    <input id=\"collapsible\" class=\"toggle\" type=\"checkbox\">\r\n    <label for=\"collapsible\" class=\"lbl-toggle\" onclick=\"writeContent()\">This article is part of the series<\/label>\r\n    <div class=\"collapsible-content\">\r\n      <div class=\"content-inner\">\r\n        <p class=\"innerContent\" id=\"innerContent\"><\/p>\r\n        <script>\r\n           function writeContent(){\r\n               var links= document.getElementById(\"series_parts\").innerHTML;\r\n               document.getElementById(\"innerContent\").innerHTML = links;\r\n           }\r\n       <\/script>\r\n      <\/div>\r\n    <\/div>\r\n<\/div>\r\n\n<p>For the complete navigation and all the basic instructions of the Angular Material series, check out: <a href=\"https:\/\/code-maze.com\/angular-material-series\/\" target=\"_blank\" rel=\"noopener noreferrer\">Introduction of the Angular Material series.<\/a><\/p>\n<p>The source code\u00a0is available\u00a0at GitHub\u00a0<a href=\"https:\/\/github.com\/CodeMazeBlog\/angular-material-series\/tree\/material-table\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Angular Material Table &#8211; Source Code<\/a><\/p>\n<p>We are going to divide this post into several sections:<\/p>\n<ul>\n<li><a href=\"#environmenthttp\">Environment, HTTP and Owner Module<\/a>\n<ul>\n<li><a href=\"#ownermodule\">Creating a New Owner Module<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#displaydata\">Using Material Table to Display Data<\/a><\/li>\n<li><a href=\"#sortingdata\">Sorting Data in Material Table<\/a><\/li>\n<li><a href=\"#filterfunctionality\">Filter Functionality in Material Table<\/a><\/li>\n<li><a href=\"#pagingfunctionality\">Paging Functionality<\/a><\/li>\n<li><a href=\"#conclusion\">Conclusion<\/a><\/li>\n<\/ul>\n<h2 id=\"environmenthttp\">Environment, HTTP and Owner Module<\/h2>\n<p>Let\u2019s start with the environment file modifications.<\/p>\n<p>We are going to modify the <code>environment.prod.ts<\/code> file first:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">export const environment = {\r\n  production: true,\r\n  urlAddress: &#039;http:\/\/www.ang-material-account-owner.com&#039;\r\n};\r\n<\/pre><br \/>\nAfter that, let\u2019s modify the<code> environment.ts<\/code> file:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">export const environment = {\r\n  production: false,\r\n  urlAddress: &#039;http:\/\/localhost:5000&#039;\r\n};\r\n<\/pre><br \/>\nHaving these environment files modified, it is time to create a service for sending the HTTP requests towards our server.<\/p>\n<p>To do that, we are going to create a service file first:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">ng g service shared\/repository --skipTests<\/pre><br \/>\nAfter creation, we have to modify that file:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">import { Injectable } from &#039;@angular\/core&#039;;\r\nimport { HttpClient, HttpHeaders } from &#039;@angular\/common\/http&#039;;\r\nimport { environment } from &#039;.\/..\/..\/environments\/environment&#039;;\r\n\r\n@Injectable({\r\n  providedIn: &#039;root&#039;\r\n})\r\nexport class RepositoryService {\r\n\r\n  constructor(private http: HttpClient) { }\r\n\r\n  public getData = (route: string) =&gt; {\r\n    return this.http.get(this.createCompleteRoute(route, environment.urlAddress));\r\n  }\r\n \r\n  public create = (route: string, body) =&gt; {\r\n    return this.http.post(this.createCompleteRoute(route, environment.urlAddress), body, this.generateHeaders());\r\n  }\r\n \r\n  public update = (route: string, body) =&gt; {\r\n    return this.http.put(this.createCompleteRoute(route, environment.urlAddress), body, this.generateHeaders());\r\n  }\r\n \r\n  public delete = (route: string) =&gt; {\r\n    return this.http.delete(this.createCompleteRoute(route, environment.urlAddress));\r\n  }\r\n \r\n  private createCompleteRoute = (route: string, envAddress: string) =&gt; {\r\n    return `${envAddress}\/${route}`;\r\n  }\r\n \r\n  private generateHeaders = () =&gt; {\r\n    return {\r\n      headers: new HttpHeaders({&#039;Content-Type&#039;: &#039;application\/json&#039;})\r\n    }\r\n  }\r\n}\r\n<\/pre><br \/>\nExcellent. We have prepared our service file. If you want to learn more about environment files, services, and HTTP, you can read that in the <a href=\"https:\/\/code-maze.com\/net-core-web-development-part9\/\" target=\"_blank\" rel=\"noopener noreferrer\">Angular Series Article<\/a> which covers all of these topics.<\/p>\n<p>One more thing that we need to do is to register <code>HttpClientModule<\/code> in the <code>app.module.ts<\/code> file:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">import { HttpClientModule } from &#039;@angular\/common\/http&#039;;<\/pre><br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">imports: [\r\n    \u2026\r\n    HttpClientModule\r\n  ],\r\n<\/pre><\/p>\n<h3 id=\"ownermodule\">Creating a New Owner Module<\/h3>\n<p>Let\u2019s create a new Owner module, and the routes for that module as well:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">ng g module owner --module app<\/pre><br \/>\nWe are going to register this module into the main routing module but in such a way to support the lazy loading feature:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">const routes: Routes = [\r\n  { path: &#039;home&#039;, component: HomeComponent},\r\n  { path: &#039;owner&#039;, loadChildren: () =&gt; import(&#039;.\/owner\/owner.module&#039;).then(m =&gt; m.OwnerModule) }, \r\n  { path: &#039;&#039;, redirectTo: &#039;\/home&#039;, pathMatch: &#039;full&#039; }\r\n];\r\n<\/pre><br \/>\nTo read more about multiple modules and lazy loading in Angular, you can visit an article on the following link\u00a0<a href=\"https:\/\/code-maze.com\/net-core-web-development-part10\/\" target=\"_blank\" rel=\"noopener noreferrer\">Lazy Loading in Angular<\/a>.<\/p>\n<p>Right now, we have to create a new component to show the list of all the owners from the database:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">ng g component owner\/owner-list --skipTests<\/pre><br \/>\n<a href=\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/05\/03-Owner-list-component.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-52321 size-full\" src=\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/05\/03-Owner-list-component.png\" alt=\"owner list component - angular material table\" width=\"1497\" height=\"135\" srcset=\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/05\/03-Owner-list-component.png 1497w, https:\/\/code-maze.com\/wp-content\/uploads\/2020\/05\/03-Owner-list-component-300x27.png 300w, https:\/\/code-maze.com\/wp-content\/uploads\/2020\/05\/03-Owner-list-component-1024x92.png 1024w, https:\/\/code-maze.com\/wp-content\/uploads\/2020\/05\/03-Owner-list-component-768x69.png 768w, https:\/\/code-maze.com\/wp-content\/uploads\/2020\/05\/03-Owner-list-component-1080x97.png 1080w\" sizes=\"auto, (max-width: 1497px) 100vw, 1497px\" \/><\/a><\/p>\n<p>We need to have routing for the components inside this module, so let\u2019s create a new routing module for the Owner module components:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">ng g module owner\/owner-routing --module owner<\/pre><br \/>\nAnd let\u2019s modify that module file:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">import { NgModule } from &#039;@angular\/core&#039;;\r\nimport { CommonModule } from &#039;@angular\/common&#039;;\r\nimport { Routes, RouterModule } from &#039;@angular\/router&#039;;\r\nimport { OwnerListComponent } from &#039;..\/owner-list\/owner-list.component&#039;;\r\n\r\nconst routes: Routes = [\r\n  { path: &#039;owners&#039;, component: OwnerListComponent }\r\n];\r\n\r\n@NgModule({\r\n  imports: [\r\n    CommonModule,\r\n    RouterModule.forChild(routes)\r\n  ],\r\n  exports: [\r\n    RouterModule\r\n  ],\r\n  declarations: []\r\n})\r\nexport class OwnerRoutingModule { }\r\n<\/pre><br \/>\nFinally, to make all this to work, we need to modify our routes in the <code>sidenav-list.component.html<\/code> file:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"xhtml\" data-enlighter-title=\"\">&lt;a mat-list-item routerLink=&quot;\/owner\/owners&quot; (click)=&quot;onSidenavClose()&quot;&gt;\r\n   &lt;mat-icon&gt;assignment_ind&lt;\/mat-icon&gt; &lt;span class=&quot;nav-caption&quot;&gt;Owner Actions&lt;\/span&gt;\r\n&lt;\/a&gt;\r\n<\/pre><br \/>\nAnd the <code>header.component.html<\/code> file:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"xhtml\" data-enlighter-title=\"\">&lt;li&gt;\r\n    &lt;a routerLink=&quot;\/owner\/owners&quot;&gt;Owner Actions&lt;\/a&gt;\r\n&lt;\/li&gt;\r\n<\/pre><br \/>\nThat is it. We can confirm now that our routing settings work as it supposed to:<\/p>\n<p><a href=\"https:\/\/code-maze.com\/wp-content\/uploads\/2018\/11\/18-Routing-completed_Owner-Module.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5118\" src=\"https:\/\/code-maze.com\/wp-content\/uploads\/2018\/11\/18-Routing-completed_Owner-Module.gif\" alt=\"routing completed - angular material table\" width=\"974\" height=\"424\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Excellent. Right now, we can dedicate our work to fetch some data from the database and show them in the material table component.<\/p>\n<h2 id=\"displaydata\"><span lang=\"EN-US\">Using Material Table to Display Data<\/span><\/h2>\n<p>Because we have created another module in our Angular app, we need to import the <code>Material module<\/code> file inside the <code>owner.module.ts<\/code> file:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">import { MaterialModule } from &#039;.\/..\/material\/material.module&#039;;<\/pre><br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">imports: [\r\n    \u2026\r\n    MaterialModule\r\n  ],\r\n<\/pre><br \/>\nOnce we create the Shared module, we will fix this code repetition (MaterialModule inside the App module and Owner module).<\/p>\n<p>For now, let\u2019s continue by creating the <code>_interface<\/code> folder and inside it the <code>owner.model.ts<\/code> file:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">export interface Owner{\r\n    id: string;\r\n    name: string;\r\n    dateOfBirth: Date;\r\n    address: string;\r\n}\r\n<\/pre><br \/>\nBecause we want to use the material table component, we need to register its own module in the\u00a0<code>material.module.ts<\/code> file:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">import { MatTableModule } from &#039;@angular\/material\/table&#039;;<\/pre><br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">imports: [\r\n    MatTableModule,\r\n<\/pre><br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">exports: [\r\n    MatTableModule,\r\n<\/pre><br \/>\nThen, let\u2019s modify the <code>owner-list.component<\/code> file:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"xhtml\" data-enlighter-title=\"\">&lt;table mat-table [dataSource]=&quot;dataSource&quot;&gt;\r\n  &lt;ng-container matColumnDef=&quot;name&quot;&gt;\r\n    &lt;th mat-header-cell *matHeaderCellDef&gt; Name &lt;\/th&gt;\r\n    &lt;td mat-cell *matCellDef=&quot;let element&quot;&gt; {{element.name}} &lt;\/td&gt;\r\n  &lt;\/ng-container&gt;\r\n\r\n  &lt;ng-container matColumnDef=&quot;dateOfBirth&quot;&gt;\r\n    &lt;th mat-header-cell *matHeaderCellDef&gt; Date of Birth &lt;\/th&gt;\r\n    &lt;td mat-cell *matCellDef=&quot;let element&quot;&gt; {{element.dateOfBirth | date}} &lt;\/td&gt;\r\n  &lt;\/ng-container&gt;\r\n\r\n  &lt;ng-container matColumnDef=&quot;address&quot;&gt;\r\n    &lt;th mat-header-cell *matHeaderCellDef&gt; Address &lt;\/th&gt;\r\n    &lt;td mat-cell *matCellDef=&quot;let element&quot;&gt; {{element.address}} &lt;\/td&gt;\r\n  &lt;\/ng-container&gt;\r\n\r\n  &lt;ng-container matColumnDef=&quot;details&quot;&gt;\r\n    &lt;th mat-header-cell *matHeaderCellDef&gt; Details &lt;\/th&gt;\r\n    &lt;td mat-cell *matCellDef=&quot;let element&quot;&gt;\r\n      &lt;button mat-icon-button color=&quot;primary&quot; (click)=&quot;redirectToDetails(element.id)&quot;&gt;\r\n          &lt;mat-icon class=&quot;mat-18&quot;&gt;reorder&lt;\/mat-icon&gt;\r\n      &lt;\/button&gt;\r\n    &lt;\/td&gt;\r\n  &lt;\/ng-container&gt;\r\n\r\n  &lt;ng-container matColumnDef=&quot;update&quot;&gt;\r\n      &lt;th mat-header-cell *matHeaderCellDef&gt; Update &lt;\/th&gt;\r\n      &lt;td mat-cell *matCellDef=&quot;let element&quot;&gt;\r\n        &lt;button mat-icon-button color=&quot;accent&quot; (click)=&quot;redirectToUpdate(element.id)&quot;&gt;\r\n            &lt;mat-icon class=&quot;mat-18&quot;&gt;system_update&lt;\/mat-icon&gt;\r\n        &lt;\/button&gt;\r\n      &lt;\/td&gt;\r\n    &lt;\/ng-container&gt;\r\n\r\n    &lt;ng-container matColumnDef=&quot;delete&quot;&gt;\r\n        &lt;th mat-header-cell *matHeaderCellDef&gt; Delete &lt;\/th&gt;\r\n        &lt;td mat-cell *matCellDef=&quot;let element&quot;&gt;\r\n          &lt;button mat-icon-button color=&quot;warn&quot; (click)=&quot;redirectToDelete(element.id)&quot;&gt;\r\n              &lt;mat-icon class=&quot;mat-18&quot;&gt;delete&lt;\/mat-icon&gt;\r\n          &lt;\/button&gt;\r\n        &lt;\/td&gt;\r\n      &lt;\/ng-container&gt;\r\n\r\n  &lt;tr mat-header-row *matHeaderRowDef=&quot;displayedColumns&quot;&gt;&lt;\/tr&gt;\r\n  &lt;tr mat-row *matRowDef=&quot;let row; columns: displayedColumns;&quot;&gt;&lt;\/tr&gt;\r\n&lt;\/table&gt;\r\n<\/pre><br \/>\nThe <code>mat-table<\/code> element transforms this table into a material one. With the <code>dataSource<\/code> attribute, we provide a data source for our table. Inside every <code>ng-container<\/code> tag, we define the column definition and the value to be displayed. It is very important to match the <code>matColumnDef<\/code> value with the property name of our <code>Owner<\/code> interface.<\/p>\n<p>Finally, in the last two <code>tr<\/code> tags, we define an order for our header columns and the row definitions. So, what we need to do right now is to create our <code>datasource<\/code> and <code>displayedColumns<\/code> properties in the <code>ownerlist.component.ts<\/code> file:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">import { RepositoryService } from &#039;.\/..\/..\/shared\/repository.service&#039;;\r\nimport { Component, OnInit } from &#039;@angular\/core&#039;;\r\nimport { MatTableDataSource } from &#039;@angular\/material\/table&#039;;\r\nimport { Owner } from &#039;..\/..\/_interface\/owner.model&#039;;\r\n\r\n@Component({\r\n  selector: &#039;app-owner-list&#039;,\r\n  templateUrl: &#039;.\/owner-list.component.html&#039;,\r\n  styleUrls: [&#039;.\/owner-list.component.css&#039;]\r\n})\r\nexport class OwnerListComponent implements OnInit {\r\n\r\n  public displayedColumns = [&#039;name&#039;, &#039;dateOfBirth&#039;, &#039;address&#039;, &#039;details&#039;, &#039;update&#039;, &#039;delete&#039;\r\n];\r\n  public dataSource = new MatTableDataSource&lt;Owner&gt;();\r\n\r\n  constructor(private repoService: RepositoryService) { }\r\n\r\n  ngOnInit() {\r\n    this.getAllOwners();\r\n  }\r\n\r\n  public getAllOwners = () =&gt; {\r\n    this.repoService.getData(&#039;api\/owner&#039;)\r\n    .subscribe(res =&gt; {\r\n      this.dataSource.data = res as Owner[];\r\n    })\r\n  }\r\n\r\n  public redirectToDetails = (id: string) =&gt; {\r\n    \r\n  }\r\n\r\n  public redirectToUpdate = (id: string) =&gt; {\r\n    \r\n  }\r\n\r\n  public redirectToDelete = (id: string) =&gt; {\r\n    \r\n  }\r\n\r\n}\r\n<\/pre><br \/>\nIf we change the order of elements inside the <code>displayedColumns<\/code> array, it will change the order of the columns inside our table.<\/p>\n<p>Right now, if we start our application and navigate to the Owner Actions menu, we are going to see a populated material table. But we are missing some styles, so let&#8217;s add those in the<code> owner-list.component.css<\/code> file:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"css\" data-enlighter-title=\"\">table {\r\n    width: 100%;\r\n    overflow-x: auto;\r\n    overflow-y: hidden;\r\n    min-width: 500px;\r\n}\r\n\r\nth.mat-header-cell {\r\n    text-align: left;\r\n    max-width: 300px;\r\n}\r\n<\/pre><br \/>\nNow we should have a better-styled table:<\/p>\n<p><a href=\"https:\/\/code-maze.com\/wp-content\/uploads\/2018\/10\/19-Mat-Table.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4895\" src=\"https:\/\/code-maze.com\/wp-content\/uploads\/2018\/10\/19-Mat-Table.png\" alt=\"mat table - angular material table\" width=\"983\" height=\"429\" srcset=\"https:\/\/code-maze.com\/wp-content\/uploads\/2018\/10\/19-Mat-Table.png 983w, https:\/\/code-maze.com\/wp-content\/uploads\/2018\/10\/19-Mat-Table-600x262.png 600w, https:\/\/code-maze.com\/wp-content\/uploads\/2018\/10\/19-Mat-Table-300x131.png 300w, https:\/\/code-maze.com\/wp-content\/uploads\/2018\/10\/19-Mat-Table-768x335.png 768w\" sizes=\"auto, (max-width: 983px) 100vw, 983px\" \/><\/a><\/p>\n<h2 id=\"sortingdata\"><span lang=\"EN-US\">Sorting Data in Material Table<\/span><\/h2>\n<p>We want to add the sorting functionality to our table, and for that purpose, we are going to use the <code>matSort<\/code> directive on the <code>table<\/code> tag. Moreover, we need to place the <code>mat-sort-header<\/code> directive for each header cell that will trigger sorting.<\/p>\n<p>So, let\u2019s do that now.<\/p>\n<p>Modifying the <code>table<\/code> tag is going to be our first task:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">&lt;table mat-table [dataSource]=&quot;dataSource&quot; matSort&gt;<\/pre><br \/>\nThen, we are going to add the <code>mat-sort-header<\/code> directive to the <code>Name<\/code>, <code>DateOfBirth<\/code>, and <code>Address<\/code> tags:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">&lt;th mat-header-cell *matHeaderCellDef mat-sort-header&gt; Name &lt;\/th&gt;\r\n...\r\n\r\n&lt;th mat-header-cell *matHeaderCellDef mat-sort-header&gt; Date of Birth &lt;\/th&gt;\r\n...\r\n\r\n&lt;th mat-header-cell *matHeaderCellDef mat-sort-header&gt; Address &lt;\/th&gt;\r\n<\/pre><br \/>\nTo make sorting functionality up and running, we need to modify the <code>owner-list.component.ts<\/code> file as well:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-highlight=\"1-2,4,9,17-19\" data-enlighter-title=\"\">import { Component, OnInit, ViewChild, AfterViewInit } from &#039;@angular\/core&#039;;\r\nimport { MatSort } from &#039;@angular\/material\/sort&#039;;\r\n...\r\nexport class OwnerListComponent implements OnInit, AfterViewInit {\r\n\r\n  public displayedColumns = [&#039;name&#039;, &#039;dateOfBirth&#039;, &#039;address&#039;, &#039;details&#039;, &#039;update&#039;, &#039;delete&#039;];\r\n  public dataSource = new MatTableDataSource&lt;Owner&gt;();\r\n\r\n  @ViewChild(MatSort) sort: MatSort;\r\n\r\n  constructor(private repoService: RepositoryService) { }\r\n\r\n  ngOnInit() {\r\n    this.getAllOwners();\r\n  }\r\n\r\n  ngAfterViewInit(): void {\r\n    this.dataSource.sort = this.sort;\r\n  }\r\n  .\r\n  .\r\n  .\r\n<\/pre><br \/>\nLastly, we need to add the <code>MatSortModule<\/code> inside of the <code>material.module.ts<\/code> file:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">import { MatSortModule } from &#039;@angular\/material\/sort&#039;;<\/pre><br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">imports: [\r\n    MatSortModule,\r\n<\/pre><br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">exports: [\r\n    MatSortModule,\r\n<\/pre><br \/>\nNow, we can check our result:<\/p>\n<p><a href=\"https:\/\/code-maze.com\/wp-content\/uploads\/2018\/11\/20-Sorting_Functionality.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5120\" src=\"https:\/\/code-maze.com\/wp-content\/uploads\/2018\/11\/20-Sorting_Functionality.gif\" alt=\"Sorting mat table\" width=\"925\" height=\"371\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>By default, sorting starts with ascending order first and then descending. We can change that behavior by adding the <code>matSortStart<\/code> attribute to <code>desc<\/code> next to the <code>matSort<\/code> directive:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">&lt;table mat-table [dataSource]=&quot;dataSource&quot; matSort matSortStart=&quot;desc&quot;&gt;<\/pre><br \/>\nIf we don\u2019t want to use <code>MatTableDataSource<\/code> for sorting, but to provide our own sorting logic, we can use the <code>(matSortChange)<\/code> event to receive the active sorting column and the sorting order as well:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">&lt;table mat-table [dataSource]=&quot;dataSource&quot; matSort (matSortChange)=&quot;customSort($event)&quot;&gt;<\/pre><br \/>\nOnce we click on the name column it will generate the following JSON object (Of course, don&#8217;t forget to add the function in the .ts file):<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">{active: &quot;name&quot;, direction: &quot;asc&quot;}\r\n\r\n1. active:&quot;name&quot;\r\n2. direction:&quot;asc&quot;\r\n3. __proto__:Object<\/pre><\/p>\n<h2 id=\"filterfunctionality\"><span lang=\"EN-US\">Filter Functionality in Material Table<\/span><\/h2>\n<p>For this functionality, we need to provide our own input field and a custom function to filter our data. Only then, we can use <code>MatTableDataSource<\/code>\u2019s filter property. To implement filtering, we are going to add the following code right above our table in the HTML file:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"xhtml\" data-enlighter-title=\"\">&lt;div fxLayout fxLayoutAlign=&quot;center center&quot;&gt;\r\n  &lt;mat-form-field fxFlex=&quot;40%&quot;&gt;\r\n    &lt;input matInput type=&quot;text&quot; (keyup)=&quot;doFilter($event.target.value)&quot; placeholder=&quot;Filter&quot;&gt;\r\n  &lt;\/mat-form-field&gt;\r\n&lt;\/div&gt;\r\n<\/pre><br \/>\nAnd then to write the following function in the component file:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">public doFilter = (value: string) =&gt; {\r\n    this.dataSource.filter = value.trim().toLocaleLowerCase();\r\n  }\r\n<\/pre><br \/>\nFinally, because we are using the <code>matInput<\/code> directive to transform regular input into the material input field, we need to register its modules inside the <code>material.module.ts<\/code> file:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">import { MatFormFieldModule } from &#039;@angular\/material\/form-field&#039;;\r\nimport { MatInputModule } from &#039;@angular\/material\/input&#039;;<\/pre><br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">imports: [\r\n    MatFormFieldModule,\r\n    MatInputModule,\r\n<\/pre><br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">exports: [\r\n    MatFormFieldModule,\r\n    MatInputModule,\r\n<\/pre><br \/>\nAs we can see from the HTML file, we are using the <code>fxLayout<\/code> directive. But, because this component is part of a new Owner module, we need to import <code>FlexLayoutModule<\/code> into the Owner module file as well:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">import { FlexLayoutModule } from &#039;@angular\/flex-layout&#039;;<\/pre><br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">imports: [\r\n    ...\r\n    FlexLayoutModule\r\n  ],\r\n<\/pre><br \/>\nOf course, this code repetition will be solved as well as soon as we create a Shared module.<\/p>\n<p>Excellent.<\/p>\n<p>Now we can inspect the result:<\/p>\n<p><a href=\"https:\/\/code-maze.com\/wp-content\/uploads\/2018\/11\/21-Filtering_Functionality.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5122\" src=\"https:\/\/code-maze.com\/wp-content\/uploads\/2018\/11\/21-Filtering_Functionality.gif\" alt=\"filter mat table - angular material table\" width=\"928\" height=\"436\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h2 id=\"pagingfunctionality\">Paging Functionality<\/h2>\n<p>To implement paging with a material table, we need to use a <code>&lt;mat-paginator&gt;<\/code> bellow our table. So, let\u2019s start implementation by adding <code>MatPaginatorModule<\/code> inside the <code>Material<\/code> module:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">import {MatPaginatorModule } from &#039;@angular\/material\/paginator&#039;;<\/pre><br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">imports: [\r\n    MatPaginatorModule,\r\n<\/pre><br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">exports: [\r\n    MatPaginatorModule,\r\n<\/pre><br \/>\nThen, let\u2019s add\u00a0<code>mat-paginator<\/code> inside the HTML file:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">&lt;mat-paginator [pageSize]=&quot;2&quot; [pageSizeOptions]=&quot;[2, 4, 6, 10, 20]&quot;&gt;\r\n&lt;\/mat-paginator&gt;\r\n<\/pre><br \/>\nAnd finally, let\u2019s modify the <code>owner-list.component.ts<\/code> file:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-highlight=\"1,5,15\" data-enlighter-title=\"\">import { MatPaginator } from &#039;@angular\/material\/paginator&#039;;\r\n\r\n...\r\n\r\n  @ViewChild(MatPaginator) paginator: MatPaginator;\r\n  \r\n  constructor(private repoService: RepositoryService) { }\r\n\r\n  ngOnInit() {\r\n    this.getAllOwners();\r\n  }\r\n\r\n  ngAfterViewInit(): void {\r\n    this.dataSource.sort = this.sort;\r\n    this.dataSource.paginator = this.paginator;\r\n  }\r\n  ...\r\n<\/pre><br \/>\nAfter these changes, we should have the following result:<\/p>\n<p><a href=\"https:\/\/code-maze.com\/wp-content\/uploads\/2018\/10\/22-Paging.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4898\" src=\"https:\/\/code-maze.com\/wp-content\/uploads\/2018\/10\/22-Paging.gif\" alt=\"paging - angular material table\" width=\"906\" height=\"556\" \/><\/a><\/p>\n<p>If we want to write our custom pagination logic, we should use the <code>(page)<\/code> output event:<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-title=\"\">&lt;mat-paginator [pageSize]=&quot;2&quot; [pageSizeOptions]=&quot;[2, 4, 6, 10, 20]&quot; (page)=&quot;pageChanged($event)&quot;&gt;\r\n&lt;\/mat-paginator&gt;\r\n<\/pre><br \/>\nFor the custom pagination logic, you will have to write a pagination logic on the Web API part. We have a great article that explains <a href=\"https:\/\/code-maze.com\/paging-aspnet-core-webapi\/\" target=\"_blank\" rel=\"noopener noreferrer\">How to Write Paging in ASP.NET Core Web API<\/a>. So, feel free to read it and acquire a better knowledge of the server-side paging as well.<\/p>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>So, that\u2019s it. Now we have our material table with all the features like sorting, paging, and filtering data.<\/p>\n<p>In this article, we have learned:<\/p>\n<ul>\n<li>How to use Environment files, HTTP client module, and Lazy Loading feature<\/li>\n<li>To create a material table<\/li>\n<li>To apply sorting, filtering, and pagination to the material table<\/li>\n<\/ul>\n<p>In the next article, we are going to <a href=\"https:\/\/code-maze.com\/angular-material-error-details-pages\/\" target=\"_blank\" rel=\"noopener noreferrer\">create error pages by focusing on the material components<\/a> and to create owner details component.<\/p>\n<!-- Shortcode [subscribe] does not exist -->\n","protected":false},"excerpt":{"rendered":"<p>We are going to divide this article into two major parts. The first\u00a0part will consist of creating environment files, HTTP repository service, and creating a new Owner module with the lazy loading feature. As you can see, everything is Angular specific, so we won\u2019t dive too deep into these sections. We already have Angular Series [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":54338,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[495],"tags":[388,192,399,400,397,396,398],"class_list":["post-4899","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-angular-material","tag-angular-material","tag-environment","tag-filtering","tag-http-service","tag-material-sorting","tag-material-table","tag-paging","et-has-post-format-content","et_post_format-et-post-format-standard"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Angular Material Table, Filtering, Sorting, Paging - Code Maze<\/title>\n<meta name=\"description\" content=\"In this article we are going to learn about Angular Material Table and its functionalities related to Filtering, Sorting and Paging.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/code-maze.com\/angular-material-table\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Angular Material Table, Filtering, Sorting, Paging - Code Maze\" \/>\n<meta property=\"og:description\" content=\"In this article we are going to learn about Angular Material Table and its functionalities related to Filtering, Sorting and Paging.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/code-maze.com\/angular-material-table\/\" \/>\n<meta property=\"og:site_name\" content=\"Code Maze\" \/>\n<meta property=\"article:published_time\" content=\"2018-11-05T07:00:35+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-01-20T11:52:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/code-maze.com\/wp-content\/uploads\/2018\/11\/angular-material-Filtering-Sorting-Paging.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1100\" \/>\n\t<meta property=\"og:image:height\" content=\"620\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Marinko Spasojevi\u0107\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/CodeMazeBlog\" \/>\n<meta name=\"twitter:site\" content=\"@CodeMazeBlog\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Marinko Spasojevi\u0107\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":[\"Article\",\"BlogPosting\"],\"@id\":\"https:\/\/code-maze.com\/angular-material-table\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/code-maze.com\/angular-material-table\/\"},\"author\":{\"name\":\"Marinko Spasojevi\u0107\",\"@id\":\"https:\/\/code-maze.com\/#\/schema\/person\/d6fa06e66820968d19b39fb63cff2533\"},\"headline\":\"Angular Material Table, Filtering, Sorting, Paging\",\"datePublished\":\"2018-11-05T07:00:35+00:00\",\"dateModified\":\"2021-01-20T11:52:29+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/code-maze.com\/angular-material-table\/\"},\"wordCount\":1378,\"commentCount\":52,\"publisher\":{\"@id\":\"https:\/\/code-maze.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/code-maze.com\/angular-material-table\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2018\/11\/angular-material-Filtering-Sorting-Paging.png\",\"keywords\":[\"angular material\",\"Environment\",\"filtering\",\"http service\",\"material sorting\",\"material table\",\"paging\"],\"articleSection\":[\"Angular Material\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/code-maze.com\/angular-material-table\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/code-maze.com\/angular-material-table\/\",\"url\":\"https:\/\/code-maze.com\/angular-material-table\/\",\"name\":\"Angular Material Table, Filtering, Sorting, Paging - Code Maze\",\"isPartOf\":{\"@id\":\"https:\/\/code-maze.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/code-maze.com\/angular-material-table\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/code-maze.com\/angular-material-table\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2018\/11\/angular-material-Filtering-Sorting-Paging.png\",\"datePublished\":\"2018-11-05T07:00:35+00:00\",\"dateModified\":\"2021-01-20T11:52:29+00:00\",\"description\":\"In this article we are going to learn about Angular Material Table and its functionalities related to Filtering, Sorting and Paging.\",\"breadcrumb\":{\"@id\":\"https:\/\/code-maze.com\/angular-material-table\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/code-maze.com\/angular-material-table\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/code-maze.com\/angular-material-table\/#primaryimage\",\"url\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2018\/11\/angular-material-Filtering-Sorting-Paging.png\",\"contentUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2018\/11\/angular-material-Filtering-Sorting-Paging.png\",\"width\":1100,\"height\":620,\"caption\":\"angular material Filtering Sorting Paging\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/code-maze.com\/angular-material-table\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/code-maze.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Angular Material Table, Filtering, Sorting, Paging\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/code-maze.com\/#website\",\"url\":\"https:\/\/code-maze.com\/\",\"name\":\"Code Maze\",\"description\":\"Learn. Code. Succeed.\",\"publisher\":{\"@id\":\"https:\/\/code-maze.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/code-maze.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/code-maze.com\/#organization\",\"name\":\"Code Maze\",\"url\":\"https:\/\/code-maze.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/code-maze.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez.png\",\"contentUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez.png\",\"width\":3511,\"height\":3510,\"caption\":\"Code Maze\"},\"image\":{\"@id\":\"https:\/\/code-maze.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/CodeMazeBlog\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/code-maze.com\/#\/schema\/person\/d6fa06e66820968d19b39fb63cff2533\",\"name\":\"Marinko Spasojevi\u0107\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/code-maze.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/marinko-1x1-3-150x150.jpg\",\"contentUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/marinko-1x1-3-150x150.jpg\",\"caption\":\"Marinko Spasojevi\u0107\"},\"description\":\"Hi, my name is Marinko Spasojevic. Currently, I work as a full-time .NET developer and my passion is web application development. Just getting something to work is not enough for me. To make it just how I like it, it must be readable, reusable, and easy to maintain. Prior to being an author on the CodeMaze blog, I had been working as a professor of Computer Science for several years. So, sharing knowledge while working as a full-time developer comes naturally to me.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/marinko-spasojevic\/\",\"https:\/\/x.com\/https:\/\/twitter.com\/CodeMazeBlog\"],\"url\":\"https:\/\/code-maze.com\/author\/marinko\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Angular Material Table, Filtering, Sorting, Paging - Code Maze","description":"In this article we are going to learn about Angular Material Table and its functionalities related to Filtering, Sorting and Paging.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/code-maze.com\/angular-material-table\/","og_locale":"en_US","og_type":"article","og_title":"Angular Material Table, Filtering, Sorting, Paging - Code Maze","og_description":"In this article we are going to learn about Angular Material Table and its functionalities related to Filtering, Sorting and Paging.","og_url":"https:\/\/code-maze.com\/angular-material-table\/","og_site_name":"Code Maze","article_published_time":"2018-11-05T07:00:35+00:00","article_modified_time":"2021-01-20T11:52:29+00:00","og_image":[{"width":1100,"height":620,"url":"https:\/\/code-maze.com\/wp-content\/uploads\/2018\/11\/angular-material-Filtering-Sorting-Paging.png","type":"image\/png"}],"author":"Marinko Spasojevi\u0107","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/CodeMazeBlog","twitter_site":"@CodeMazeBlog","twitter_misc":{"Written by":"Marinko Spasojevi\u0107","Est. reading time":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["Article","BlogPosting"],"@id":"https:\/\/code-maze.com\/angular-material-table\/#article","isPartOf":{"@id":"https:\/\/code-maze.com\/angular-material-table\/"},"author":{"name":"Marinko Spasojevi\u0107","@id":"https:\/\/code-maze.com\/#\/schema\/person\/d6fa06e66820968d19b39fb63cff2533"},"headline":"Angular Material Table, Filtering, Sorting, Paging","datePublished":"2018-11-05T07:00:35+00:00","dateModified":"2021-01-20T11:52:29+00:00","mainEntityOfPage":{"@id":"https:\/\/code-maze.com\/angular-material-table\/"},"wordCount":1378,"commentCount":52,"publisher":{"@id":"https:\/\/code-maze.com\/#organization"},"image":{"@id":"https:\/\/code-maze.com\/angular-material-table\/#primaryimage"},"thumbnailUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2018\/11\/angular-material-Filtering-Sorting-Paging.png","keywords":["angular material","Environment","filtering","http service","material sorting","material table","paging"],"articleSection":["Angular Material"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/code-maze.com\/angular-material-table\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/code-maze.com\/angular-material-table\/","url":"https:\/\/code-maze.com\/angular-material-table\/","name":"Angular Material Table, Filtering, Sorting, Paging - Code Maze","isPartOf":{"@id":"https:\/\/code-maze.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/code-maze.com\/angular-material-table\/#primaryimage"},"image":{"@id":"https:\/\/code-maze.com\/angular-material-table\/#primaryimage"},"thumbnailUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2018\/11\/angular-material-Filtering-Sorting-Paging.png","datePublished":"2018-11-05T07:00:35+00:00","dateModified":"2021-01-20T11:52:29+00:00","description":"In this article we are going to learn about Angular Material Table and its functionalities related to Filtering, Sorting and Paging.","breadcrumb":{"@id":"https:\/\/code-maze.com\/angular-material-table\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/code-maze.com\/angular-material-table\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/code-maze.com\/angular-material-table\/#primaryimage","url":"https:\/\/code-maze.com\/wp-content\/uploads\/2018\/11\/angular-material-Filtering-Sorting-Paging.png","contentUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2018\/11\/angular-material-Filtering-Sorting-Paging.png","width":1100,"height":620,"caption":"angular material Filtering Sorting Paging"},{"@type":"BreadcrumbList","@id":"https:\/\/code-maze.com\/angular-material-table\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/code-maze.com\/"},{"@type":"ListItem","position":2,"name":"Angular Material Table, Filtering, Sorting, Paging"}]},{"@type":"WebSite","@id":"https:\/\/code-maze.com\/#website","url":"https:\/\/code-maze.com\/","name":"Code Maze","description":"Learn. Code. Succeed.","publisher":{"@id":"https:\/\/code-maze.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/code-maze.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/code-maze.com\/#organization","name":"Code Maze","url":"https:\/\/code-maze.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/code-maze.com\/#\/schema\/logo\/image\/","url":"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez.png","contentUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez.png","width":3511,"height":3510,"caption":"Code Maze"},"image":{"@id":"https:\/\/code-maze.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/CodeMazeBlog"]},{"@type":"Person","@id":"https:\/\/code-maze.com\/#\/schema\/person\/d6fa06e66820968d19b39fb63cff2533","name":"Marinko Spasojevi\u0107","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/code-maze.com\/#\/schema\/person\/image\/","url":"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/marinko-1x1-3-150x150.jpg","contentUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/marinko-1x1-3-150x150.jpg","caption":"Marinko Spasojevi\u0107"},"description":"Hi, my name is Marinko Spasojevic. Currently, I work as a full-time .NET developer and my passion is web application development. Just getting something to work is not enough for me. To make it just how I like it, it must be readable, reusable, and easy to maintain. Prior to being an author on the CodeMaze blog, I had been working as a professor of Computer Science for several years. So, sharing knowledge while working as a full-time developer comes naturally to me.","sameAs":["https:\/\/www.linkedin.com\/in\/marinko-spasojevic\/","https:\/\/x.com\/https:\/\/twitter.com\/CodeMazeBlog"],"url":"https:\/\/code-maze.com\/author\/marinko\/"}]}},"_links":{"self":[{"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/posts\/4899","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/comments?post=4899"}],"version-history":[{"count":0,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/posts\/4899\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/media\/54338"}],"wp:attachment":[{"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/media?parent=4899"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/categories?post=4899"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/tags?post=4899"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}