feat(client): POST client address && fix(client): fixed sorting and pagination in view clients (#115)
* feat(client): POST client address && fix(client): fixed sorting and pagination in view clients
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {Component, OnInit, ViewChild} from '@angular/core';
|
||||
import {Component, OnInit, ViewChild, ViewEncapsulation} from '@angular/core';
|
||||
import {MatPaginator, MatSort, MatTableDataSource} from '@angular/material';
|
||||
import { Response} from '@angular/http';
|
||||
import {ClientsService} from './clients.service';
|
||||
@@ -7,7 +7,9 @@ import { Observable } from 'rxjs';
|
||||
@Component({
|
||||
selector: 'mifosx-clients',
|
||||
templateUrl: './clients.component.html',
|
||||
styleUrls: ['./clients.component.scss']
|
||||
styleUrls: ['./clients.component.scss'],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
|
||||
})
|
||||
export class ClientsComponent implements OnInit {
|
||||
post: any = [];
|
||||
@@ -18,21 +20,24 @@ export class ClientsComponent implements OnInit {
|
||||
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||
@ViewChild(MatSort) sort: MatSort;
|
||||
|
||||
constructor(private clientService: ClientsService) {
|
||||
// GET from clients API
|
||||
this.clientService.getClients()
|
||||
.subscribe(
|
||||
(res => {
|
||||
// console.log(res);
|
||||
this.ELEMENT_DATA = res;
|
||||
this.dataSource = new MatTableDataSource(this.ELEMENT_DATA);
|
||||
})
|
||||
);
|
||||
}
|
||||
constructor(private clientService: ClientsService) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.dataSource.paginator = this.paginator;
|
||||
this.dataSource.sort = this.sort;
|
||||
this.getClients();
|
||||
}
|
||||
|
||||
// GET from clients API
|
||||
getClients() {
|
||||
this.clientService.getClients()
|
||||
.subscribe(
|
||||
(res => {
|
||||
console.log(res);
|
||||
this.dataSource = new MatTableDataSource(res);
|
||||
this.dataSource.paginator = this.paginator;
|
||||
this.dataSource.sort = this.sort;
|
||||
this.dataSource.sortingDataAccessor = (data, header) => data[header];
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
applyFilter(filterValue: string) {
|
||||
|
||||
Reference in New Issue
Block a user