@angular/material/table#MatTableDataSource TypeScript Examples

The following examples show how to use @angular/material/table#MatTableDataSource. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: account-struct.component.ts    From assetMG with Apache License 2.0 6 votes vote down vote up
addAdGroupsToTable() {
    this._adGroupRows = this.createAdGroupRows();
    // Assign the data to the data source for the table to render
    this.dataSource = new MatTableDataSource(this._adGroupRows);
    this.dataSource.paginator = this.paginator;
    this.dataSource.sort = this.sort;

    this.applyFilterPredicate();
    // Adjust sorting criteria
    this.dataSource.sortingDataAccessor = (item, property) => {
      switch (property) {
        case 'adgroup-sel':
          return this.adgroup_sel.selected.includes(item);
        case 'headline-sel':
        case 'desc-sel':
          return (
            this.headline_sel.selected.includes(item) ||
            this.description_sel.selected.includes(item)
          );
        default:
          return item[property];
      }
    };
  }
Example #2
Source File: ranking.component.ts    From oss-github-benchmark with GNU General Public License v3.0 6 votes vote down vote up
sortAndFilter(institutions: any): void {
    let i = 0;
    institutions.forEach((institution) => {
      const len = institution.repo_names.length;
      institutions[i].repo_names = institution.repo_names
        .slice(0, this.reposToDisplay)
        .join(', ');
      if (len >= this.reposToDisplay) {
        institutions[i].repo_names += '...';
      }
      if (
        this.sectorFilters.some((value: any) => {
          return value.sector === institution.sector;
        })
      ) {
        this.sectorFilters[
          this.sectorFilters.findIndex((value: any) => {
            return value.sector === institution.sector;
          })
        ].count += 1;
      }

      i++;
    });

    this.dataSource = new MatTableDataSource(institutions);
    this.dataSource.sort = this.sort;

    this.sort.active = sortState.active;
    this.sort.direction = sortState.direction;
    this.sort.sortChange.emit(sortState);
    this.dataSource.paginator = this.paginator;
    this.numInstitutions = this.dataSource.filteredData.length;
    timeout(() => {
      this.includeForksChange(false);
    }, 100);
  }
Example #3
Source File: view-deals.component.ts    From careydevelopmentcrm with MIT License 6 votes vote down vote up
private handleDeals(deals: Deal[]) {
    this.dataLoading = false;
    this.dataSource = new MatTableDataSource(deals);
    this.dataSource.paginator = this.paginator;
    this.dataSource.sortingDataAccessor = sortingDataAccessor;
    this.dataSource.sort = this.sort;
    this.setFilterData();
    this.dataSource.filterPredicate = this.createFilter();
  }
Example #4
Source File: log-module.component.ts    From 6PG-Dashboard with MIT License 6 votes vote down vote up
async ngOnInit() { 
    const id = this.route.snapshot.paramMap.get('id');

    const log = await this.botService.getSavedLog(id);
    this.changes = log.changes.reverse();
    
    this.dataSource = new MatTableDataSource(this.changes);
    this.dataSource.paginator = this.paginator;
    this.dataSource.sort = this.sort;
  }
Example #5
Source File: room.component.ts    From WiLearning with GNU Affero General Public License v3.0 6 votes vote down vote up
constructor(
    public i18n: I18nService,
    private logger: LoggerService,
    private dialog: MatDialog,
    private http: HttpClient,
    private snackbar: MatSnackBar,
    private eventbus: EventbusService,
    private breakpointObserver: BreakpointObserver,
  ) {
    this.eventbus.room$.subscribe((event: IEventType) => {
      if ( event.type === EventType.room_created ) {
        this.roomList();
      }
    });
    this.dataSource = new MatTableDataSource<RoomElement>(this.rooms);
    this.isSmallScreen = breakpointObserver.isMatched('(max-width: 599px)');
    if (this.isSmallScreen) {
      this.displayedColumns = ['select', 'name', 'id', 'operation'];
    }
  }
Example #6
Source File: table.component.ts    From material-reusable-table with Apache License 2.0 5 votes vote down vote up
public tableDataSource = new MatTableDataSource([]);
Example #7
Source File: employee-table.component.ts    From angular-material-admin with MIT License 5 votes vote down vote up
public ngOnInit(): void {
    this.dataSource = new MatTableDataSource<Employee>(this.employeeTableData);

    this.dataSource.paginator = this.paginator;
  }
Example #8
Source File: wallet.component.ts    From EXOS-Core with MIT License 5 votes vote down vote up
public dataSource = new MatTableDataSource<TransactionInfo>();
Example #9
Source File: users.component.ts    From mysql_node_angular with MIT License 5 votes vote down vote up
dataSource = new MatTableDataSource();
Example #10
Source File: employee-table.component.ts    From angular-material-admin with MIT License 5 votes vote down vote up
public dataSource: MatTableDataSource<Employee>;
Example #11
Source File: table.component.ts    From material-reusable-table with Apache License 2.0 5 votes vote down vote up
setTableDataSource(data: any) {
    this.tableDataSource = new MatTableDataSource<any>(data);
    this.tableDataSource.paginator = this.matPaginator;
    this.tableDataSource.sort = this.matSort;
  }
Example #12
Source File: list-requests.component.ts    From yii-debug-frontend with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
getDebugsList(): void {
        this.loading = true;
        this.debugService.getList().subscribe((response) => {
            this.loading = false;
            this.debugsList = new MatTableDataSource<IndexNode>(response);
            this.debugsList.sort = this.sort;
        });
    }
Example #13
Source File: user-ranking.component.ts    From oss-github-benchmark with GNU General Public License v3.0 5 votes vote down vote up
dataSource: any = new MatTableDataSource();
Example #14
Source File: list-requests.component.ts    From yii-debug-frontend with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
debugsList: MatTableDataSource<IndexNode>;
Example #15
Source File: employee-table.component.ts    From angular-material-admin with MIT License 5 votes vote down vote up
public showFilterInput(): void {
    this.isShowFilterInput = !this.isShowFilterInput;
    this.dataSource = new MatTableDataSource<Employee>(this.employeeTableData);
  }
Example #16
Source File: table-sorting.component.ts    From matx-angular with MIT License 5 votes vote down vote up
dataSource = new MatTableDataSource(ELEMENT_DATA);
Example #17
Source File: table.component.ts    From geonetwork-ui with GNU General Public License v2.0 5 votes vote down vote up
dataSource: MatTableDataSource<any>
Example #18
Source File: explore-item.component.ts    From oss-github-benchmark with GNU General Public License v3.0 5 votes vote down vote up
ngOnInit(): void {
    this.dataService.loadRepoData().then((repoData) => {
      repoData = repoData.jsonData;
      this.item = Object.assign({}, this.data.institution);
      this.item.repos = this.item.repos.map((repoUUID) => {
        const t = repoData.find((repo) => {
          return repo.uuid == repoUUID;
        });
        console.log(repoUUID);
        return t;
      });
      this.includeForks = this.data.includeForks;
      if (this.item.repos) {
        this.item.repos.forEach((repo) => {
          repo.name = lowerCase(repo.name);
        });
      }
      if (this.item.repos.length > 0) {
        this.dataSource = new MatTableDataSource(this.item.repos);
      }
      this.sort.active = sortState.active;
      this.sort.direction = sortState.direction;
      this.sort.sortChange.emit(sortState);
      this.dataSource.filterPredicate = (data: any, filter: string) => {
        let datastring: string = '';
        let property: string;
        let filterNew = this.recordFilter;
        for (property in data) {
          datastring += data[property];
        }
        datastring = datastring.replace(/\s/g, '').toLowerCase();
        filterNew = filterNew.replace(/\s/g, '').toLowerCase();
        return (
          datastring.includes(filterNew) && (this.includeForks || !data.fork)
        );
      };
      this.triggerFilter();
      if (this.item.org_names.length == 1) {
        this.displayedColumns = this.displayedColumns.filter(
          (e) => e !== 'organization'
        );
      }
      if (this.includeForks) {
        this.includeForksChange(false);
      }
      console.log(this.item);
    });
  }
Example #19
Source File: account-struct.component.ts    From assetMG with Apache License 2.0 5 votes vote down vote up
dataSource: MatTableDataSource<AdGroupRow>;
Example #20
Source File: stats-table.component.ts    From zorro-fire-log with MIT License 5 votes vote down vote up
dataSource = new MatTableDataSource<StatisticsModel>([]);
Example #21
Source File: log-module.component.ts    From 6PG-Dashboard with MIT License 5 votes vote down vote up
dataSource = new MatTableDataSource();
Example #22
Source File: mat-table.component.ts    From flingo with MIT License 5 votes vote down vote up
private setupSubscriptions() {
        this.subscriptions.add(
            this.tableData$.pipe(filter((t) => !!t)).subscribe((data) => {
                setTimeout(() => {
                    this.dataSource = new MatTableDataSource<any>(data);
                    this.dataSource.sort = this.sort;

                    if (this.showPagination && this.paginator) {
                        this.dataSource.paginator = this.paginator;

                        const numOfPages = this.paginator.getNumberOfPages();

                        this.pageCountArray = this.getPageCountArray(numOfPages);

                        this.changeDetectorRef.detectChanges();
                    }
                });
            })
        );

        if (this.showPagination) {
            this.subscriptions.add(
                combineLatest([
                    this.staffWebTableService.currentPageIndex$,
                    this.staffWebTableService.currentPageSize$
                ]).subscribe(([pageIndex, pageSize]) => {
                    if (!this.skipToPageFormGroup) {
                        this.buildSkipToPageForm(pageIndex + 1);
                    }

                    setTimeout(() => {
                        this.paginator.pageIndex = pageIndex;
                        this.paginator.pageSize = pageSize;

                        this.paginator.page.emit({
                            pageSize: pageSize,
                            pageIndex: pageIndex,
                            length: this.paginator.getNumberOfPages()
                        });
                    });
                })
            );
        }

        if (this.skipToPageFormGroup) {
            this.subscriptions.add(
                this.skipToPageFormGroup.get('pageIndex').valueChanges.subscribe((value: number) => {
                    const index = value - 1;
                    const size = this.paginator.pageSize;
                    const length = this.paginator.getNumberOfPages();

                    this.staffWebTableService.setPageIndex(index);

                    this.updatePageIndex(index, size, length);
                })
            );
        }
    }
Example #23
Source File: material-table.component.ts    From matx-angular with MIT License 5 votes vote down vote up
ngOnInit() {
    this.displayedColumns = this.tableService.getDataConf().map((c) => c.prop)
    this.dataSource = new MatTableDataSource(this.tableService.getAll());
  }
Example #24
Source File: mat-table-query-reflector.component.ts    From nghacks with MIT License 5 votes vote down vote up
ngOnInit(): void {
    // Simulating a server call
    setTimeout(() => {
      this.dataSource = new MatTableDataSource<PeriodicElement>(ELEMENT_DATA);
      this.dataSource.paginator = this.paginator;
      this.dataSource.sort = this.sort;
    }, 1000);
  }
Example #25
Source File: offers.component.ts    From bitcoin-s-ts with MIT License 5 votes vote down vote up
// Grid config
  dataSource = new MatTableDataSource(<IncomingOffer[]>[])
Example #26
Source File: account.component.ts    From budget-angular with GNU General Public License v3.0 5 votes vote down vote up
users = new MatTableDataSource<User>();
Example #27
Source File: mat-table-query-reflector.component.ts    From nghacks with MIT License 5 votes vote down vote up
dataSource: MatTableDataSource<PeriodicElement>;
Example #28
Source File: block.component.ts    From blockcore-hub with MIT License 5 votes vote down vote up
dataSource = new MatTableDataSource<any>();
Example #29
Source File: ngmat-table-query-reflector.directive.ts    From nghacks with MIT License 5 votes vote down vote up
@Input() dataSource: MatTableDataSource<any>;