🎨 Frontend & UI

Data Table Component

Using and customizing the smart data table for listing entities.

Overview

Gauzy uses Angular2 Smart Table (angular2-smart-table) for data display across the application. All list views use a consistent table component with filtering, sorting, pagination, and actions.

Basic Usage

@Component({
  template: `
    <angular2-smart-table
      [settings]="settings"
      [source]="source"
      (edit)="onEditRow($event)"
      (delete)="onDeleteRow($event)"
    >
    </angular2-smart-table>
  `,
})
export class MyListComponent {
  settings = {
    actions: {
      add: false,
      edit: { editButtonContent: '<i class="nb-edit"></i>' },
      delete: { deleteButtonContent: '<i class="nb-trash"></i>' },
    },
    columns: {
      name: { title: "Name", type: "string" },
      email: { title: "Email", type: "string" },
      status: {
        title: "Status",
        type: "custom",
        renderComponent: StatusBadgeComponent,
      },
      createdAt: {
        title: "Created",
        type: "custom",
        renderComponent: DateViewComponent,
      },
    },
  };
}

Server-Side Data Source

import { ServerDataSource } from "angular2-smart-table";

export class MyListComponent {
  source: ServerDataSource;

  constructor(private http: HttpClient) {
    this.source = new ServerDataSource(http, {
      endPoint: "/api/my-entity",
      dataKey: "items",
      totalKey: "total",
      pagerPageKey: "page",
      pagerLimitKey: "limit",
      sortFieldKey: "orderBy",
      sortDirKey: "order",
    });
  }
}

Custom Render Components

ComponentTypeDescription
DateViewComponentDateFormatted dates
StatusBadgeComponentBadgeColored status badges
AvatarComponentImageUser/employee avatar
ActionComponentActionsRow action buttons

Edit this page

Copyright © 2023-Present Ever Co. LTD.Docs by Sourcey