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 🙏

© 2026 – Pkg Stats / Ryan Hefner

ngx-s-data-table

v0.2.6

Published

Data table with filtering, pagination, checkbox selection, click event and expandable row.

Readme

Data table with filtering, pagination, checkbox selection, click event and expandable row.

Table of Contents


Description

Data table with support for essential features such as filtering, pagination, row selection, row expansion and checkbox based selection that works based on a class and data source provided. Has high customization and robust built-in validation. Needs a class and its instances as a data source to work with.

Features

  • Pagination: The data is paginated based on the quantity per page provided.
  • Filtering: Generic or column based filters to specify the displayed data.
  • Click: Click event to handle actions based on an element selected by the user.
  • Expand: Expandable rows that display a property value and/or ng-template content specified as HTML.
  • Checkbox Selection: Emit a list of elements selected by the user.
  • Composition of Classes: Display data from composed objects based on a property mapping provided.
  • Date Format: Formats dates based on input provided.
  • Built-in Validation: Automatically performs multiple validations to ensure proper functionality, providing explanation in the console.
  • Robust Customization: Use the PropertyMapping exported class to specify how the table should handle the data provided.

Getting Started

Step 1 - Installing ngx-s-data-table:

NPM

npm install ngx-s-data-table

Step2 - Importing the module:

example.component.ts

import  { Component }  from  '@angular/core';
import  { DataTableModule }  from  'ngx-s-data-table';

@Component({
selector:  'app-example',
imports:  [DataTableModule],
templateUrl:  './example.component.html',
styleUrl:  './example.component.css'
})

export  class  ExampleComponent { }

example.module.ts

import  { NgModule }  from  '@angular/core';
import  { CommonModule }  from  '@angular/common';
import  { ExampleComponent }  from  './example.component';
import  { DataTableModule }  from  'ngx-s-data-table';

@NgModule({

declarations:  [ExampleComponent],
imports:  [
CommonModule,
DataTableModule
],

exports:  [ExampleComponent]
})
export  class  ExampleModule  {  }

Usage

Basic:

Use the ngx-s-data-table component with a data source and corresponding class:

import  { Component }  from  '@angular/core';
import  { users }  from  './sample-data.data';
import  { User }  from  '../classes/user.class';

@Component({
selector:  'app-example',
standalone:  false,
templateUrl:  './example.component.html',
styleUrl:  './example.component.css'

})

export  class  ExampleComponent  {
	// Replace the class and data source with your own.
	dataClass  =  User;
	dataSource  =  users;
}

In template use the ngx-s-data-table providing the source and class

<ngx-s-data-table
	[dataClass]="dataClass"
	[dataSource]="dataSource"
>
</ngx-s-data-table>

The table should be filled with the data provided.

Customization and compositions The library exports a PropertyMapping class that allows you to specify how the table should handle the data. Especially useful when working with complex or nested data structures.

import  { Component }  from  '@angular/core';
import  { orders }  from  './sample-data.data';
import  { Order }  from  '../classes/order.class';
import  { PropertyMapping }  from  'ngx-s-data-table';

@Component({
	selector:  'app-example',
	standalone:  false,
	templateUrl:  './example.component.html',
	styleUrl:  './example.component.css'
})

export  class  ExampleComponent  {
	dataClass  =  Order;
	dataSource  =  orders;

	propertyMappings:  PropertyMapping[]  =  [
		// both are compositions, this is telling the table to display the "name"
		// property for each one of them
		new  PropertyMapping("user")
			.withCompositionProperty("name"),
		new  PropertyMapping("products")
			.withCompositionProperty("name"),
		// this is adding a collumn that will display the price of each product
		new  PropertyMapping("products").namedAs("prices")
			.withCompositionProperty("price"),
		// this tells the table that the id will be unique and is meant to not
		// be displayed
		new  PropertyMapping("id")
			.beingPrimaryKey().beingIgnored()
	];
}

And then input the mappings specified to the component

<ngx-s-data-table
	[dataClass]="dataClass"
	[dataSource]="dataSource"
	[mappingParams]="propertyMappings"
>
</ngx-s-data-table>

To handle compositions with same property meant to be displayed, it's possible to input the component with a default one. Many more default behaviors can be assigned inputing data to the component, see the API for further information.

<ngx-s-data-table
	[dataClass]="dataClass"
	[dataSource]="dataSource"
	[mappingParams]="propertyMappings"
	[defaultCompositionProperty]="'name'"
	[primaryKeyProperty]="'id'"
	[expandableProperty]="'htmlDescription'"
	[headBackgroundColor]="'rgb(150, 150, 150)'"
>
</ngx-s-data-table>

Options The table by default won't have click, expansion, filtering or pagination features enabled, needing you to specify which features to use and, possibly, define a valid primary key to assure proper behavior.

<ngx-s-data-table
	[dataClass]="dataClass"
	[dataSource]="dataSource"
	[primaryKeyProperty]="'id'"

	[expandableProperty]="'htmlDescription'"
	[useExpantion]="true"
	
	[useGeneralFilter]="true"
	[useColumnsFilter]="true"
	
	[usePagination]="true"
	[pageSize]="25"
	
	[useSelection]="true"
	(selectedActionEvent)="handleSelectedItens($event)"
>
</ngx-s-data-table>

Again, look for the API for further information.

API

DataTable component API

| Input | Type| Usage |----------|----------|----------| | [dataClass] | new (...args: any[]) => any | Class of the data source. | | [dataSource] | Record<string, any>[] | Data source, an array of objects to be displayed. | | [mappingParams] | PropertyMapping[] | Specific configuration for the properties to be displayed. |
| [headBackgroundColor] | string | background-color css attribute value for the thead element. |
| [primaryKeyProperty] | string | Name of the property that is unique across the source of data. | | [defaultCompositionProperty] | string | Name of the default property to be displayed whenever there is a composition. | | [expandableProperty] | string | Name of the property which value is to be displayed as HTML whenever a row is expanded. | | [useExpantion] | boolean | Enables the row expantion feature. | | [useGeneralFilter] | boolean | Enables a general filter. | | [useColumnsFilter] | boolean | Enables a column based filter. | | [useSelection] | boolean | Enables a checkbox based selection. | | [usePagination] | boolean | Enables pagination. | | [useClick] | boolean | Enables emitting click events by clicking a row. |
| [pageSize] | number | Number of rows to be displayed by page. Default is 50. | | [dateFormat] | string | Date format. Example: "MM/dd/yyyy". |

| [Output] | Event type | Usage
| -------|-------|------| | (clickEvent) | any | emits the value of the primary key property from the clicked row object | | (selectedActionEvent) | Record<string, any>[] | emits the selected rows objects |

PropertyMapping class API

| Method | Usage | |----------|----------| | new PropertyMapping(propertyName: string, isIgnored: boolean = false)| PropertyMapping class constructor, defines the mapped property name | | namedAs(columnName: string) | Defines the column name for the property specified | | withCompositionProperty(compositionPropertyName: string) | Defines which property within the object should be displayed by the table | | beingPrimaryKey(isPrimaryKey: boolean = true) | Defines the property as a primary key | | beingIgnored(isIgnored: boolean = true) | Defines that the property shouldn't be displayed | | beingExpandableContent(isExpandableContent: boolean = true) | Defines the property as the content to be displayed when the row's object is expanded | | get propertyName() | gets the property name | | get columnName() | gets the column name | | isIgnored() | gets if the property is to be ignored | | isPrimaryKey | gets if the property is a primary key | | isExpandableContent | gets if the property is expandable content | | compositionPropertyName | gets the name of the property whose value is to be displayed | |