diff options
Diffstat (limited to 'ecomp-sdk/portalsdk-tag-library/projects/portalsdk-tag-lib')
2 files changed, 24 insertions, 9 deletions
diff --git a/ecomp-sdk/portalsdk-tag-library/projects/portalsdk-tag-lib/src/lib/rdp/rdp-data-table/rdp-data-table.component.html b/ecomp-sdk/portalsdk-tag-library/projects/portalsdk-tag-lib/src/lib/rdp/rdp-data-table/rdp-data-table.component.html index 4f98abd5..e5d08e51 100644 --- a/ecomp-sdk/portalsdk-tag-library/projects/portalsdk-tag-lib/src/lib/rdp/rdp-data-table/rdp-data-table.component.html +++ b/ecomp-sdk/portalsdk-tag-library/projects/portalsdk-tag-lib/src/lib/rdp/rdp-data-table/rdp-data-table.component.html @@ -51,8 +51,8 @@ <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> </table> <!-- </rdp-scroll-container> --> - <div *ngIf="isPaginationRequired"> + <div [hidden]="!isPaginationRequired"> <mat-paginator [length]="totalRowsCount" #paginator [pageSizeOptions]="[5, 10, 25, 100]" [pageSize]="pageSize" - (page)="pageEvent = $event; onPaginationChange($event)"></mat-paginator> + ></mat-paginator> </div> </div>
\ No newline at end of file diff --git a/ecomp-sdk/portalsdk-tag-library/projects/portalsdk-tag-lib/src/lib/rdp/rdp-data-table/rdp-data-table.component.ts b/ecomp-sdk/portalsdk-tag-library/projects/portalsdk-tag-lib/src/lib/rdp/rdp-data-table/rdp-data-table.component.ts index b833c6fb..954d0941 100644 --- a/ecomp-sdk/portalsdk-tag-library/projects/portalsdk-tag-lib/src/lib/rdp/rdp-data-table/rdp-data-table.component.ts +++ b/ecomp-sdk/portalsdk-tag-library/projects/portalsdk-tag-lib/src/lib/rdp/rdp-data-table/rdp-data-table.component.ts @@ -59,7 +59,14 @@ export class RdpDataTableComponent<T> implements OnChanges, AfterViewInit, OnIni @Input() settings: any; @ViewChild(MatSort) sort: MatSort; - @ViewChild(MatPaginator) paginator: MatPaginator; + //@ViewChild(MatPaginator) paginator: MatPaginator; + private paginator: MatPaginator; + + @ViewChild(MatPaginator) set matPaginator(mp: MatPaginator) { + this.paginator = mp; + this.setData(this.data); + } + @ViewChild(MatTable) table: MatTable<T>; @ViewChild('input') input: ElementRef; @@ -74,7 +81,7 @@ export class RdpDataTableComponent<T> implements OnChanges, AfterViewInit, OnIni isEditMode: boolean; isSearchEnabled: boolean; isServerSidePaginationEnabled: boolean = false; - showAddButton: boolean = true; + showAddButton: boolean = false; result : any; totalRowsCount: any; showSpinner: boolean; @@ -88,7 +95,7 @@ export class RdpDataTableComponent<T> implements OnChanges, AfterViewInit, OnIni } ngAfterViewInit() { - if(this.isServerSidePaginationEnabled){ + if(this.settings && this.settings.isServerSidePaginationEnabled && this.data){ this.sort.sortChange.subscribe(() => this.paginator.pageIndex = 0); @@ -108,12 +115,16 @@ export class RdpDataTableComponent<T> implements OnChanges, AfterViewInit, OnIni tap(() => this.loadData(this.paginator.pageIndex, this.paginator.pageSize)) ).subscribe(); } - - this.dataSource.paginator = this.paginator; - this.dataSource.sort = this.sort; + if(this.data) { + this.dataSource.paginator = this.paginator; + this.dataSource.sort = this.sort; + } } ngOnChanges() { + if(this.data) { + this.setData(this.data); + } if (this.settings) { console.log("Table setting Objects >>>>", this.settings); @@ -134,6 +145,8 @@ export class RdpDataTableComponent<T> implements OnChanges, AfterViewInit, OnIni if (this.settings.isReadOnly) { this.showAddButton = false; + }else{ + this.showAddButton = true; } if (this.settings.isTableSearchEnabled) { @@ -159,7 +172,7 @@ export class RdpDataTableComponent<T> implements OnChanges, AfterViewInit, OnIni } setData(data) { - if(this.settings.isServerSidePaginationEnabled){ + if(this.settings && this.settings.isServerSidePaginationEnabled){ console.log("Server side pagination is enabled"); this.dataSource = new RDPDataSource(); this.dataSource.loadData(this.settings.applicationService,'', this.sort.active, this.sort.direction, 0, this.settings.paginationsSize); @@ -170,6 +183,8 @@ export class RdpDataTableComponent<T> implements OnChanges, AfterViewInit, OnIni console.log("Server side pagination is not enabled"); if (Array.isArray(data)) { this.dataSource.data = data; + this.dataSource.paginator = this.paginator; + this.dataSource.sort = this.sort; this.totalRowsCount = data.length; } } |