How to use the @angular/material/table.MatTableDataSource function in @angular/material

To help you get started, we’ve selected a few @angular/material examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NationalBankBelgium / stark / packages / stark-ui / src / modules / table / components / table.component.ts View on Github external
private initializeDataSource(): void {
		this.dataSource = new MatTableDataSource(this.data);

		// if there are observers subscribed to the StarkPagination event, it means that the developer will take care of the pagination
		// so we just re-emit the event from the Stark Pagination component (online mode)
		if (this.paginationChanged.observers.length > 0) {
			this.starkPaginator.paginated.subscribe((paginateEvent: StarkPaginateEvent) => {
				this.paginationChanged.emit(paginateEvent);
			});
		} else {
			// if there are no observers, then the data will be paginated internally in the MatTable via the Stark paginator event (offline mode)
			this.dataSource.paginator = this.starkPaginator;
		}

		this.starkPaginator.emitMatPaginationEvent();

		this.dataSource.filterPredicate = (rowData: object, globalFilter: string) => {
			const matchFilter: boolean[] = [];
github aiten / CNCLib / Src / Server / ClientApp / src / app / serialporthistory / serialporthistory-gcode.component / serialporthistory-gcode.component.ts View on Github external
import { SerialPortHistoryPreviewGlobal } from "../models/serialporthistory.global";

@Component({
  selector: 'serialporthistorygcode',
  templateUrl: './serialporthistory-gcode.component.html',
  styleUrls: ['./serialporthistory-gcode.component.css']
})
export class SerialPortHistoryGCodeComponent implements OnChanges, OnInit, OnDestroy {

  forserialportid: number = -1;

  @Input()
  autoreloadonempty: boolean = false;

  serialcommands: SerialCommand[] = [];
  serialcommandsDataSource = new MatTableDataSource(this.serialcommands);

  displayedColumns: string[] = [/* 'SeqId', */ 'sentTime', 'commandText', 'replyType', 'resultText', 'replyReceivedTime'];

  @ViewChild(MatPaginator)
  paginator: MatPaginator;

  private hubConnection: HubConnection;
  private _initDone: boolean = false;

  constructor(
    private serivalServerService: SerialServerService,
    public serialServer: SerialServerConnection,
    public previewGlobal: SerialPortHistoryPreviewGlobal
  ) {
  }
github OpenSlides / OpenSlides / client / src / app / site / motions / modules / category / components / category-list / category-list.component.ts View on Github external
public ngOnInit(): void {
        super.setTitle('Categories');

        this.dataSource = new MatTableDataSource();
        this.repo.getViewModelListObservable().subscribe(viewCategories => {
            if (viewCategories && this.dataSource) {
                this.dataSource.data = viewCategories;
            }
        });
    }
github bkimminich / juice-shop / frontend / src / app / order-history / order-history.component.ts View on Github external
for (const order of orders) {
        const products: StrippedProduct[] = []
        for (const product of order.products) {
          products.push({
            id: product.id,
            name: product.name,
            price: product.price,
            quantity: product.quantity,
            total: product.total
          })
        }
        this.orders.push({
          orderId: order.orderId,
          totalPrice: order.totalPrice,
          bonus: order.bonus,
          products: new MatTableDataSource(products),
          delivered: order.delivered
        })
      }
    },(err) => console.log(err))
  }
github notadd / ng-notadd / src / app / main / applications / roles-permissions / roles / roles.component.ts View on Github external
ngOnInit() {
        this.dataSource = new MatTableDataSource([{
            id: '1',
            name: '管理员',
            status: true,
            description: '描述'
        }, {
            id: '2',
            name: '普通用户',
            status: false,
            description: '描述'
        }]);
        this.displayedColumns = ['select', 'id', 'name', 'status', 'description', 'actions'];
        this.selection = new SelectionModel(true, []);

        this.dataSource.paginator = this.paginator;
        this.dataSource.sort = this.sort;
    }
github senstate / platform / apps / senstate-dashboard / src / app / components / tab-content / log-viewer / log-viewer.component.ts View on Github external
ngOnChanges(changes: SimpleChanges): void {
    if (changes['logArray']) {
      this.dataSource = new MatTableDataSource(this.logArray || []);
      this.setDataSourceAttributes();
    }
  }
github apereo / cas-management / webapp / cas-mgmt-webapp-client / projects / management / src / app / registry / domains / domains.component.ts View on Github external
.subscribe((data: {resp: DomainRpc[]}) => {
          this.dataSource = new MatTableDataSource(data.resp);
          this.dataSource.paginator = this.paginator.paginator;
        },
        error => this.snackBar.open(
github angular / components / src / material-examples / table-selection / table-selection-example.ts View on Github external
{position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O'},
  {position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F'},
  {position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne'},
];

/**
 * @title Table with selection
 */
@Component({
  selector: 'table-selection-example',
  styleUrls: ['table-selection-example.css'],
  templateUrl: 'table-selection-example.html',
})
export class TableSelectionExample {
  displayedColumns: string[] = ['select', 'position', 'name', 'weight', 'symbol'];
  dataSource = new MatTableDataSource(ELEMENT_DATA);
  selection = new SelectionModel(true, []);

  /** Whether the number of selected elements matches the total number of rows. */
  isAllSelected() {
    const numSelected = this.selection.selected.length;
    const numRows = this.dataSource.data.length;
    return numSelected === numRows;
  }

  /** Selects all rows if they are not all selected; otherwise clear selection. */
  masterToggle() {
    this.isAllSelected() ?
        this.selection.clear() :
        this.dataSource.data.forEach(row => this.selection.select(row));
  }
github Bee-Mar / mmpm / gui / src / app / components / mmpm-local-packages / mmpm-local-packages.component.ts View on Github external
this.dataStore.upgradeablePackages.subscribe((upgradeable) => {
        this.upgradeablePackages = upgradeable?.packages;

        this.upgradeablePackages?.forEach((upgradeablePackage: MagicMirrorPackage) => {
          pkgs.forEach((installedPkg: MagicMirrorPackage, index: number) => {
            if (this.mmpmUtility.isSamePackage(upgradeablePackage, installedPkg)) {
              this.isUpgradeable[index] = true;
            }
          });
        });
      });

      this.packages = pkgs;
      this.selection = new SelectionModel(true, []);
      this.dataSource = new MatTableDataSource(this.packages);
      this.dataSource.paginator = this.paginator;
      this.dataSource.sort = this.sort;

      this.tableUtility = new MagicMirrorTableUtility(this.selection, this.dataSource, this.sort, this.dialog);
    });
  }
github aiten / CNCLib / Src / Serial.Server / ClientApp / src / app / serialportpending / serialportpending.component.ts View on Github external
async refresh(): Promise {

    if (this._initDone) {
      this.serialcommands = await this.serivalServerService.getPending(this.forserialportid);

      this.serialcommandsDataSource = new MatTableDataSource(this.serialcommands);
      this.serialcommandsDataSource.paginator = this.paginator;
    }
  }