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

gridjs-angular

v2.0.0

Published

Angular wrapper for [Grid.js](https://github.com/grid-js/gridjs)

Downloads

884

Readme

gridjs-angular

Angular wrapper for Grid.js

gridjs-angular repository on GitHub GridJS peer Dependency Version

Install

npm install gridjs gridjs-angular

Usage

In your component template

import { Component } from '@angular/core';
import { GridjsAngularModule } from 'gridjs-angular';
import { Config } from 'gridjs';

@Component({
  standalone: true,
  imports: [GridJsAngularComponent],
  template: `
    <gridjs-angular
      [gridConfig]="gridConfig"
      (cellClick)="handleCellClick($event)"
      (rowClick)="handleRowClick($event)"
      (beforeLoad)="handleBeforeLoad($event)"
      (gridLoad)="handleGridLoad($event)"
    ></gridjs-angular>
  `
})
class ExampleComponent {
  public gridConfig: Config = {
    columns: ['Name', 'Email', 'Phone Number'],
    data: [
      ['John', '[email protected]', '(353) 01 222 3333'],
      ['Mark', '[email protected]', '(01) 22 888 4444'],
      ['Eoin', '[email protected]', '0097 22 654 00033'],
      ['Sarah', '[email protected]', '+322 876 1233'],
      ['Afshin', '[email protected]', '(353) 22 87 8356']
    ]
  };

  handleCellClick(event: any) {
    console.log('cellClicked', event);
  }

  handleRowClick(event: any) {
    console.log('rowClicked', event);
  }

  handleBeforeLoad(event: any) {
    console.log('beforeLoad', event);
  }

  handleGridLoad(event: any) {
    console.log('load', event);
  }
}

Finally don't forget to add gridjs theme to your angular.json file, or import it some other way.

styles: ["node_modules/gridjs/dist/theme/mermaid.min.css"]

Inputs

  • You can pass all Grid.js configs to the <gridjs-angular> component as inputs. See Grid.js Config for more details.

  • gridConfig You can pass Grid.js config as one object and it will be merged with other Grid.js inputs.

  • plugins Grid.js plugins array. See Grid.js Plugins

Outputs

  • You can bind to all Grid.js events as outputs. Additionally, the load event can also be accessed via gridLoad (to avoid conflict with the native DOM load event). See Grid.js Events

Can I Grid.js rendering helpers? Yes

  • Using h function is working fine. See this example plugin.
 {
    id: 'myplugin',
    component: h(() => h('h1', {}, 'Hello world!'), {}),
    position: PluginPosition.Header,
  }
  • You can also use html in column formatter like this.
 {
    name: 'Email',
    formatter: (_, row) => html(
        `<a href='mailto:${row.cells[1].data}'>${row.cells[1].data}</a>`
      )
  }

Can I use Angular template syntax in plugins, formatters, etc?

Not currently.

You can't use Angular template syntax in Grid.js plugins, formatters, etc. because they cannot be connected to Angular's change detection system. You can use h function or html function to create custom HTML for your grid.

Development

The gridjs-angular repository is a monorepo that uses Nx and pnpm.

Useful commands

  • pnpm install - Install all dependencies
  • nx serve demo - Run demo app
  • nx migrate latest - Update Nx to the latest version, and upgrade all packages from package.json to their latest version