Getting Started Introduction

Introduction




Logo Logo



NgxPanemuTable is an Angular table component. It is designed to be easy to use. Most work will be in typescript file, while the html file only needs to have a very simple panemu-table tag.

See on Stackblitz

Features

  • [NEW] inline editing.
  • Declarative table definition in typescript. Very little code in html needed.
  • Sane defaults that can be overriden app-wide and per table basis.
  • Pagination. More flexible than common pagination.
    • Previous page of first page overflow to last page and vice versa.
    • User can input arbitrary range.
    • Client or server side. Client side pagination is provided, server side implementation is up to you.
    • Developer can create custom pagination component. See Custom Pagination.
  • Filtering.
    • Provided filter editors for string, date, datetime and key-value pair.
    • You can create custom filter editor.
    • Filter behavior can be customized. See Global Search.
    • Support between operator using dot and comma. Dot represent greater/less and equal. Comma represent greater/less whithout equal.
amount: 1.,10 is translated to `amount >= 1 and amount < 10`
amount: 1,.10 is translated to `amount > 1 and amount <= 10`

This is a quick demo of PanemuTableComponent, PanemuPaginationComponent, PanemuQueryComponent and PanemuSettingComponent.

Country
Verified
true
/ 51
Id
Name
Email
Gender
Country
Amount
Date Info
Verified
Enrolled
Last Login
Philippines (7)
United States (2)
Indonesia (16)
China (25)
Netherlands (1)
Cuba (1)
Brazil (8)
Peru (3)
Mongolia (1)
Jamaica (1)
Ukraine (4)
Sweden (2)
Poland (7)
Macedonia (1)
Iran (1)
Bulgaria (1)
Colombia (1)
Russia (5)
Japan (4)
Hungary (1)
Mexico (1)
Ivory Coast (1)
Senegal (1)
Albania (1)
Czech Republic (3)
Kyrgyzstan (1)
Croatia (1)
Panama (1)
Denmark (1)
Morocco (1)
Nigeria (2)
France (1)
Tunisia (1)
Afghanistan (2)
Canada (1)
Haiti (1)
Thailand (1)
Bosnia and Herzegovina (1)
Finland (1)
Portugal (4)
Georgia (1)
Greece (2)
Argentina (3)
Burkina Faso (1)
Honduras (1)
Spain (1)
Eritrea (1)
Guatemala (1)
South Africa (1)
Mauritania (1)
Norway (1)
TypeScript
HTML
SCSS
import { Component, OnInit, signal, TemplateRef, viewChild } from '@angular/core';
import { ColumnType, ComputedColumn, DefaultCellRenderer, DefaultRowGroupRenderer, PanemuPaginationComponent, PanemuQueryComponent, PanemuSettingComponent, PanemuTableComponent, PanemuTableController, PanemuTableDataSource, PanemuTableService, TickColumnClass } from 'ngx-panemu-table';
import { People } from '../model/people';
import { DataService } from '../service/data.service';
import { FilterCountryCellComponent } from './custom-cell/filter-country-cell.component';
import { PeopleFormComponent } from './custom-cell/people-form.component';

@Component({
  templateUrl: 'all-features-client.component.html',
  imports: [PanemuTableComponent, PanemuPaginationComponent, PanemuQueryComponent, PanemuSettingComponent],
  standalone: true,
  styleUrl: 'all-features-client.component.scss'
})

export class AllFeaturesClientComponent implements OnInit {
  genderMap = signal({});
  sendEmailTemplate = viewChild<TemplateRef<any>>('sendEmailTemplate');
  actionCellTemplate = viewChild<TemplateRef<any>>('actionCellTemplate');
  countryFooter = viewChild<TemplateRef<any>>('countryFooter');
  clmAction: ComputedColumn = {
    type: ColumnType.COMPUTED,
    formatter: (val: any) => '',
    cellRenderer: DefaultCellRenderer.create(this.actionCellTemplate),
    expansion: { component: PeopleFormComponent },
    sticky: 'end',
    width: 80,
    resizable: false,
    cellStyle: (_: string) => 'border-left-color: rgba(0,0,0, .12); border-left-width: 1px; border-left-style: solid;'
  };

  columns = this.pts.buildColumns<People>([
    new TickColumnClass<People>({ width: 50 }),
    { field: 'id', type: ColumnType.INT, width: 60},
    { field: 'name', width: 150 },
    {
      field: 'email', width: 230, expansion: {
        component: this.sendEmailTemplate,
        isDisabled: (row) => {
          return row.country == 'Indonesia'
        },
      }
    },
    { field: 'gender', width: 80, type: ColumnType.MAP, valueMap: this.genderMap },
    {
      field: 'country', width: 150, type: ColumnType.MAP, valueMap: this.dataService.getCountryMap(),
      cellRenderer: FilterCountryCellComponent.create(this.onCountryFilterClick.bind(this)),
      rowGroupRenderer: DefaultRowGroupRenderer.create({ footerComponent: this.countryFooter })
    },
    { field: 'amount', width: 100, type: ColumnType.DECIMAL },
    {
      type: ColumnType.GROUP, label: 'Date Info', children: [
        { field: 'enrolled', width: 150, type: ColumnType.DATE },
        { field: 'last_login', width: 180, type: ColumnType.DATETIME },
      ]
    },
    { field: 'verified', width: 80, type: ColumnType.MAP, valueMap: { true: 'Yes', false: 'No' } },
    this.clmAction,
  ]
  )
  datasource = new PanemuTableDataSource<People>;
  controller = PanemuTableController.create<People>(this.columns, this.datasource);

  constructor(private dataService: DataService, public pts: PanemuTableService) { }

  ngOnInit() {
    //set initial grouping
    this.controller.groupByColumns = [{ field: 'country' }]

    //set inital filtering
    this.controller.criteria = [{ field: 'verified', value: 'true' }]

    this.dataService.getPeople().subscribe(result => {
      this.datasource.setData(result);
      this.controller.reloadData();
    });

    //pretend genderMap is taken from server data
    setTimeout(() => {
      this.genderMap.set({ F: 'Female', M: 'Male' })
    }, 1000);
  }

  onCountryFilterClick(value: any, propName: string) {
    this.controller.criteria = [{ field: propName, value: value }]
    this.controller.reloadData();
  }

  edit(row: People) {
    this.controller.expand(row, this.clmAction)
  }

  delete(row: People) {
    alert('Delete ' + JSON.stringify(row))

  }

}

More In The Future

These features are not developed yet. Please create a ticket in our repository if you need them so we know what to prioritize.

  • Virtual scroll with variable row height.

Releases:

v.0.4.0

  • [Breaking Change] Persist state now has a way to pick what states to save rather than always saving all states. See this page.
  • Icons can be changed. See Icons

v.0.3.0

  • Inline editing

v.0.2.0

  • Transpose selected row.

v.0.0.9

  • New PanemuSettingComponent as the UI to change columns visibility, position and stickiness.
  • Save table states (column structure, pagination, filtering, sorting and grouping)
  • Support cell rowspan and colspan using RowRenderer.

v.0.0.7

  • Virtual scroll
  • Table footer
  • RowGroup now customizable and can have footer

Support Us

Buy Me a Coffee at ko-fi.com

About Panemu

We are software development company. Contact us if you want to build a top notch software.