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

  • 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.
  • Filtering.

    • Provided filter editors for string, date and key-value pair.
    • You can create custom filter editor.
    • 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`
  • Row Grouping.

    • Support group level pagination.
    • Customizable row group header and footer. See Custom Row Group.
  • Column header

    • Group multiple columns under one cell header.
    • Support custom cell header renderer. You can put anything in column header.
  • Column Resizable.

  • User can change column visibility, position and stickiness at runtime. See PanemuSettingComponent.

  • Save table states:

    • Columns visibility, position and stickiness.
    • Filter, grouping, sorting and pagination.

    If user changes any of those, go to other and back, the states are restored. See Persist States.

  • Customizable table cell.

    • Support custom cell using ng-template or angular component.
    • Support custom cell formatting and styling
    • Cell expansion. See Cell Expansion. ✨
  • Sticky column, header and footer

  • Cell colspan and rowspan. See Cell Spanning.

  • Export to CSV. See PanemuTableController.getCsvData() . ✨

  • Handle huge data using virtual scroll. Now it doesn't support variable row height. But it will in the future.

splitscreen_top
Country
Verified
search
true
/ 51
Id
Name
Email
Gender
Country
Amount
Date Info
Verified
Enrolled
Last Login
arrow_rightPhilippines (7)
arrow_rightUnited States (2)
arrow_rightIndonesia (16)
arrow_rightChina (25)
arrow_rightNetherlands (1)
arrow_rightCuba (1)
arrow_rightBrazil (8)
arrow_rightPeru (3)
arrow_rightMongolia (1)
arrow_rightJamaica (1)
arrow_rightUkraine (4)
arrow_rightSweden (2)
arrow_rightPoland (7)
arrow_rightMacedonia (1)
arrow_rightIran (1)
arrow_rightBulgaria (1)
arrow_rightColombia (1)
arrow_rightRussia (5)
arrow_rightJapan (4)
arrow_rightHungary (1)
arrow_rightMexico (1)
arrow_rightIvory Coast (1)
arrow_rightSenegal (1)
arrow_rightAlbania (1)
arrow_rightCzech Republic (3)
arrow_rightKyrgyzstan (1)
arrow_rightCroatia (1)
arrow_rightPanama (1)
arrow_rightDenmark (1)
arrow_rightMorocco (1)
arrow_rightNigeria (2)
arrow_rightFrance (1)
arrow_rightTunisia (1)
arrow_rightAfghanistan (2)
arrow_rightCanada (1)
arrow_rightHaiti (1)
arrow_rightThailand (1)
arrow_rightBosnia and Herzegovina (1)
arrow_rightFinland (1)
arrow_rightPortugal (4)
arrow_rightGeorgia (1)
arrow_rightGreece (2)
arrow_rightArgentina (3)
arrow_rightBurkina Faso (1)
arrow_rightHonduras (1)
arrow_rightSpain (1)
arrow_rightEritrea (1)
arrow_rightGuatemala (1)
arrow_rightSouth Africa (1)
arrow_rightMauritania (1)
arrow_rightNorway (1)
TypeScript
HTML
SCSS
import { Component, OnInit, signal, TemplateRef, viewChild } from '@angular/core';
import { ColumnType, ComputedColumn, DefaultCellRenderer, DefaultRowGroupRenderer, PanemuPaginationComponent, PanemuQueryComponent, 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],
  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: 50},
    { 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))

  }

  exportCsv() {
    /**
     * The getCsvData() can accept parameter to exclude header or row group.
     * {includeRowGroup: false, includeHeader: false}
     */
    const csvString = this.controller.getCsvData();

    const dl = "data:text/csv;charset=utf-8," + csvString;
    window.open(encodeURI(dl))
  }

}

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.

  • Global search.
  • Display transposed row in a dialog.
  • Virtual scroll with variable row height.

Releases:

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

v.0.0.6

  • Cell expansion
  • Export to CSV

v.0.0.5

  • Group multiple columns under one cell header

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.