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

@transunion-ui/tablejs

v2.2.23

Published

Tablejs ========

Downloads

234

Readme

Tablejs

Tablejs is an open-source solution for displaying complex grid content in Angular. Tablejs provides high performance grids supporting millions of rows of content and enables easy integration into familiar HTML, CSS, and Javascript concepts. Look below for an example of a grid with several features enabled.

Grid Example

Please visit our GitHub for more resources: Demo API Documentation Examples

Instructions for using Tablejs.

Grid Features

  1. Infinite scrolling
  2. Resizable columns
  3. Reorderable columns
  4. Nested headers
  5. Utilizes standard HTML tables
  6. Expandable Rows
  7. Linked table resizing
  8. Easy resize and reorder event handling
  9. Custom filtering
  10. Cell editing
  11. CSS styling
  12. Nested Tables in expandable rows
  13. Screen reader compatible
  14. Print fidelity

Usage

How to Install

npm install --save @transunion-ui/tablejs

Import Module

import { TablejsModule } from '@transunion-ui/tablejs'

Enable grid Functionality

Wrap the tablejs-grid component around your table data:

<tablejs-grid>
	<table>
		…
	</table>
</tablejs-grid>

Designate the grid’s rows by adding the tablejsGridRow directive to the table’s rows (tr):

<tablejs-grid>
	<table>
		<thead>
			<tr tablejsGridRow>
				…
			</tr>
		</thead>
	</table>
</tablejs-grid>

Resize Column Functionality

Designate which elements you would like to use as your resizable grip/handle by adding the resizableGrip directive:

<tablejs-grid>
	<table>
		<thead>
			<tr tablejsGridRow>
				<th resizableGrip><div>Header 1</div></th>
					…
				</th>
				<th>
					<div resizableGrip></div>
					<div>Header 2</div>
				</th>
			</tr>
		</thead>
	</table>
</tablejs-grid>

Note: The entire header can be used as a resizable element, but keep in mind that if you would like to enable sorting based on clicking the header, you may want to create an icon inside the header specifically for resize functionality

The grid relies on tying classes together for resize functionality. The tablejsDataColClasses directive designates which columns a header columns should have width control over. This would be a th or td tag. Notice you can include a list of classes for header columns that span multiple columns. See the example below:

Header 1 below resizes both Sub Header 1 and Sub Header 2 columns proportionately. To tie the table body column cells to the headers, the tablejsDataColClass directive is added. In the example below, Header 1 resizes columns with tablejsDataColClass set to class1 and class2. Sub Header 1 only changes the width of the columns containing class1 and Sub Header 2 only changes the width of the column containing class2. For greatly improved perfomance, include an initialWidth directive on each column containing the tablejsDataColClass directive so that the tablejsGrid directive does not need to access the DOM for widths on instantiation.

<tablejs-grid>
	<table>
		<thead>
			<tr tablejsGridRow>
				<th tablejsDataColClasses="class1, class2" colspan="2" >
					<div resizableGrip></div>
					<div>Header 1</div>
				</th>
			</tr>
			<tr tablejsGridRow>
				<th tablejsDataColClasses="class1">
					<div resizableGrip></div>
					<div>Sub Header 1</div>
				</th>
				<th tablejsDataColClasses="class2">
					<div resizableGrip></div>
					<div>Sub Header 2</div>
				</th>
			</tr>
		</thead>
		<tbody>
			<tr tablejsGridRow>
				<td><div tablejsDataColClass="class1" initialWidth="300">Content in cell 1</div></td>
				<td><div tablejsDataColClass="class2" initialWidth="300">Content in cell 2</div></td>
		</tbody>
	</table>
</tablejs-grid>

For proper resizing of the infinite scrolling component, include the tablejsInfiniteScroll directive on your cdk-virtual-scroll-viewport component:

<cdk-virtual-scroll-viewport class="tall-viewport" tablejsInfiniteScroll autosize>
	…
</cdk-virtual-scroll-viewport>

Reorder Column Functionality

To add column reorderability to a column, add the reorderCol directive:

<tablejs-grid>
	<table>
		<thead>
			<tr tablejsGridRow>
				<th reorderCol><div>Header 1</div></th>
					…
				</th>
			</tr>
		</thead>
	</table>
</tablejs-grid>

Next, create a handle for the user to pull on in order to reorder the column by adding the reorderGrip directive:

<tablejs-grid>
	<table>
		<thead>
			<tr tablejsGridRow>
				<th reorderCol>
					<div reorderGrip></div> 
					<div>Header 1</div>
				</th>
			</tr>
		</thead>
	</table>
</tablejs-grid>

A ghost drag and drop object is displayed while dragging to reorder a column. Sometimes you may not want to show the entire column header object to display. You can filter out selected elements by passing a filter function via the dragAndDropGhostFilter directive.

<tablejs-grid [dragAndDropGhostFilter]="dragDropFilter">
	<table>
		<thead>
			<tr tablejsGridRow>
				<th reorderCol>
					<div reorderGrip></div> 
					<div>Header 1</div>
				</th>
			</tr>
		</thead>
	</table>
</tablejs-grid>

In your component, you would write the dragDropFilter function you supplied. This example filters out all i tags.

dragDropFilter(el: HTMLElement) {
    return (el.tagName !== 'I');
}

Disabling selected rows from reordering

The reordering relies on the css grid functionality. To disable a row from reordering, simply set the grid-column-start and grid-column-end styles on the td or th tags. This is especially useful for expandable and collapsible rows.

<tablejs-grid [dragAndDropGhostFilter]="dragDropFilter">
	<table>
		<tbody>
			<tr tablejsGridRow>
				<td reorderCol style=”grid-column-start: 1; grid-column-end: 11;“>
					…
				</td>
			</tr>
		</tbody>
	</table>
</tablejs-grid>