npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngx-table-with-pagination

v0.0.21

Published

Implementation of Table component (Features - Filter and sorting) with pagination

Downloads

59

Readme

NgxTableWithPagination

This library was generated with Angular CLI version 18.1.0.

We are still building this library, stay tuned. For any queries Contact.

Getting started

Use the setup instructions below or go through.

Install dependencies

$ npm install --save ngx-table-with-pagination

Import styles in styles.css

@import '../node_modules/ngx-table-with-pagination/styles.css';

Set the Table's configuration in a parent component (where sorting and filtering is handled by the table component itself)

import { Component } from '@angular/core';
import { ClickEventModel, FilterModel, FilterType, TableComponent } from '@ngx-table-with-pagination';

@Component({
  selector: 'app-static-data',
  standalone: true,
  imports: [TableComponent],
  templateUrl: './static-data.component.html',
})
export class StaticDataComponent {
  title = 'ngx-table-with-pagination-demo';
  dataList!: any;

  filterConfig: FilterModel[] = [
    {
      type: FilterType.TEXT_SEARCH,
      control: 'name',
    },
    {
      type: FilterType.DROPDOWN_SEARCH,
      control: 'club',
    },
    {
      type: FilterType.SORT,
      control: 'age',
    },
    {
      type: FilterType.DROPDOWN_SEARCH,
      control: 'grade',
    },
  ];

  constructor() {
    const res = [
      {
        name: 'Alice',
        age: 18,
        grade: '12th',
        club: 'Science Olympiad',
        action: ['Delete'],
      },
      {
        name: 'Bob',
        age: 17,
        grade: '11th',
        club: 'Debate Team',
      },
      {
        name: 'Charlie',
        age: 19,
        grade: '12th',
        club: 'Art Club',
      },
      {
        name: 'Diana',
        age: 16,
        grade: '10th',
        club: 'Mathletes',
      },
      {
        name: 'Ethan',
        age: 18,
        grade: '12th',
        club: 'Robotics Club',
      },
      {
        name: 'Fiona',
        age: 17,
        grade: '11th',
        club: 'Newspaper Staff',
      },
      {
        name: 'Gabriel',
        age: 19,
        grade: '12th',
        club: 'Chess Club',
      },
      {
        name: 'Hannah',
        age: 16,
        grade: '10th',
        club: 'Student Government',
      },
      {
        name: 'Isaac',
        age: 18,
        grade: '12th',
        club: 'Band',
      },
      {
        name: 'Jessica',
        age: 17,
        grade: '11th',
        club: 'Model UN',
      },
      {
        name: 'Kelvin',
        age: 19,
        grade: '12th',
        club: 'Drama Club',
      },
      {
        name: 'Lily',
        age: 16,
        grade: '10th',
        club: 'Volunteer Club',
      },
      {
        name: 'Michael',
        age: 18,
        grade: '12th',
        club: 'Football Team',
      },
      {
        name: 'Nora',
        age: 17,
        grade: '11th',
        club: 'Yearbook Committee',
      },
      {
        name: 'Olivia',
        age: 19,
        grade: '12th',
        club: 'Environmental Club',
      },
      {
        name: 'Peter',
        age: 16,
        grade: '10th',
        club: 'Coding Club',
      },
      {
        name: 'Quinn',
        age: 18,
        grade: '12th',
        club: 'Track & Field',
      },
      {
        name: 'Ruby',
        age: 17,
        grade: '11th',
        club: 'Cheerleading Squad',
      },
      {
        name: 'Sophia',
        age: 19,
        grade: '12th',
        club: 'National Honor Society',
      },
      {
        name: 'Thomas',
        age: 16,
        grade: '10th',
        club: 'History Club',
      },
      {
        name: 'Thomasa',
        age: 17,
        grade: '10th',
        club: 'History Club',
      },
      {
        name: 'Thomasb',
        age: 18,
        grade: '10th',
        club: 'History Club',
      },
      {
        name: 'Thomasc',
        age: 19,
        grade: '10th',
        club: 'History Club',
      },
      {
        name: 'Thomasd',
        age: 20,
        grade: '10th',
        club: 'History Club',
      },
      {
        name: 'Thomase',
        age: 21,
        grade: '10th',
        club: 'History Club',
      },
      {
        name: 'Thomasf',
        age: 22,
        grade: '10th',
        club: 'History Club',
      },
      {
        name: 'Thomasg',
        age: 23,
        grade: '10th',
        club: 'History Club',
      },
      {
        name: 'Alice',
        age: 24,
        grade: '10th',
        club: 'History Club',
      },
    ];
    this.dataList = res as any[];
  }

  handleClickEvent({ eventType, row, column }: ClickEventModel): void {
    console.log(eventType, row, column);
  }
}
<ngx-table [filterConfig]="filterConfig" (clickEvent)="handleClickEvent($event)" [dataList]="dataList" />

Set the Table's configuration in a parent component (where sorting and filtering is handled by the parent through the api calls)

import { Component } from '@angular/core';
import {
  ClickEventModel,
  FilterModel,
  FilterType,
  SearchData,
  SortDataModel,
  TableComponent,
  TableComponentModel,
  TableConfig,
} from '@ngx-table-with-pagination';

@Component({
  selector: 'app-home',
  standalone: true,
  imports: [TableComponent],
  templateUrl: './home.component.html',
})
export class HomeComponent implements TableComponentModel {
  res = [
    {
      name: 'Alice',
      age: 18,
      grade: '12th',
      club: 'Science Olympiad',
      action: ['Delete'],
    },
    {
      name: 'Bob',
      age: 17,
      grade: '11th',
      club: 'Debate Team',
    },
    {
      name: 'Charlie',
      age: 19,
      grade: '12th',
      club: 'Art Club',
    },
    {
      name: 'Diana',
      age: 16,
      grade: '10th',
      club: 'Mathletes',
    },
    {
      name: 'Ethan',
      age: 18,
      grade: '12th',
      club: 'Robotics Club',
    },
    {
      name: 'Fiona',
      age: 17,
      grade: '11th',
      club: 'Newspaper Staff',
    },
    {
      name: 'Gabriel',
      age: 19,
      grade: '12th',
      club: 'Chess Club',
    },
    {
      name: 'Hannah',
      age: 16,
      grade: '10th',
      club: 'Student Government',
    },
    {
      name: 'Isaac',
      age: 18,
      grade: '12th',
      club: 'Band',
    },
    {
      name: 'Jessica',
      age: 17,
      grade: '11th',
      club: 'Model UN',
    },
    {
      name: 'Kelvin',
      age: 19,
      grade: '12th',
      club: 'Drama Club',
    },
    {
      name: 'Lily',
      age: 16,
      grade: '10th',
      club: 'Volunteer Club',
    },
    {
      name: 'Michael',
      age: 18,
      grade: '12th',
      club: 'Football Team',
    },
    {
      name: 'Nora',
      age: 17,
      grade: '11th',
      club: 'Yearbook Committee',
    },
    {
      name: 'Olivia',
      age: 19,
      grade: '12th',
      club: 'Environmental Club',
    },
    {
      name: 'Peter',
      age: 16,
      grade: '10th',
      club: 'Coding Club',
    },
    {
      name: 'Quinn',
      age: 18,
      grade: '12th',
      club: 'Track & Field',
    },
    {
      name: 'Ruby',
      age: 17,
      grade: '11th',
      club: 'Cheerleading Squad',
    },
    {
      name: 'Sophia',
      age: 19,
      grade: '12th',
      club: 'National Honor Society',
    },
    {
      name: 'Thomas',
      age: 16,
      grade: '10th',
      club: 'History Club',
    },
    {
      name: 'Thomasa',
      age: 17,
      grade: '10th',
      club: 'History Club',
    },
    {
      name: 'Thomasb',
      age: 18,
      grade: '10th',
      club: 'History Club',
    },
    {
      name: 'Thomasc',
      age: 19,
      grade: '10th',
      club: 'History Club',
    },
    {
      name: 'Thomasd',
      age: 20,
      grade: '10th',
      club: 'History Club',
    },
    {
      name: 'Thomase',
      age: 21,
      grade: '10th',
      club: 'History Club',
    },
    {
      name: 'Thomasf',
      age: 22,
      grade: '10th',
      club: 'History Club',
    },
    {
      name: 'Thomasg',
      age: 23,
      grade: '10th',
      club: 'History Club',
    },
    {
      name: 'Alice',
      age: 24,
      grade: '10th',
      club: 'History Club',
    },
  ];

  filterConfig: FilterModel[] = [
    {
      type: FilterType.TEXT_SEARCH,
      control: 'name',
    },
    {
      type: FilterType.DROPDOWN_SEARCH,
      control: 'club',
    },
    {
      type: FilterType.SORT,
      control: 'grade',
    },
  ];
  handleClickEvent({ eventType, row, column }: ClickEventModel): void {
    console.log('Clicked action', eventType, 'for row:', row, 'and column:', column);
  }

  handleFilterEvent(filterArray: SearchData[]): void {
    console.log('Filter applied:', filterArray);
  }

  handleSortingEvent(sortData: SortDataModel): void {
    console.log('Sorted by:', sortData.column, 'with order:', sortData.order);
  }

  handlePaginationEvent(tableConfig: TableConfig): void {
    console.log('Pagination applied:', tableConfig);
  }
}
<div id="tableComp">
  <p class="">home works!</p>

  <ngx-table
    isWithAPI
    (paginationEvent)="handlePaginationEvent($event)"
    [dataList]="res"
    (clickEvent)="handleClickEvent($event)"
    (sortEvent)="handleSortingEvent($event)"
    (filterEvent)="handleFilterEvent($event)"
    [filterConfig]="filterConfig" />
</div>

Issue Reporting

If you have found a bug, please report it in this repository's issues section.