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

cuppa-ng2-grid

v1.0.5

Published

Angular 2 data grid component written in pure angular 2 and typescript

Downloads

15

Readme

Cuppa Angular 2 Data Grid Component

npm version

Render 10,000+ Records with high performance

It is often required that, large datasets needs to be rendered in the front-end table. Cuppa Angular 2 Data Grid components handles 10K + records with high performance. Developed using Angular 2, TypeScript, HTML, CSS

Features

  • Render 10k + records with high performance
  • Faster Rendering without browser hanging.
  • Faster Sorting algorithm
  • Faster filtering and search algorithm

Demo

View the Demo here.

Getting Started

Installation

  • Install with npm: npm install cuppa-ng2-grid

Usage

  • Import CuppaDataGridModule from the installed package into your module as follows:
import { CuppaDataGridModule } from 'cuppa-ng2-grid/cuppa-ng2-dataGrid';
  • Declare the data grid module in your ngModule as follows:
@NgModule({
  bootstrap: [ AppComponent ],
  declarations: [
    AppComponent,
    NoContentComponent  ],
  imports: [
    BrowserModule, 
    FormsModule,
    HttpModule,
    CuppaDataGridModule // Import DataGrid module variable here
  ]
})

Initialize

HTML

  • Place the component html tag in the template where the table needs to be rendered.
<cuppa-datagrid [datalist] = "arrayList" [config]="config" (onRowSelect)="onRowClick($event)"></cuppa-datagrid>

JS

  • Component requires a config object to configure the grid and datalist to pass data to the component, as follows:
export class AppComponent implements OnInit {
      private config = {
        title: "Cuppa Data Table",
        w: 300,
        h: 300,
        itemHeight: 31,
        totalRows: 10000,
        items: this.arrayList,
        sort:{'id':'desc'}
      }
      private arrayList:any[] =
            [
                {"id":1,"name":"Mayo","mobile":9240592804},
                {"id":2,"name":"Nelson","mobile":9008774782},
                {"id":3,"name":"Nichols","mobile":9965852134},
                {"id":4,"name":"Summers","mobile":9600712058},
                {"id":5,"name":"Novak","mobile":9045924098},
                {"id":6,"name":"Bell","mobile":9001240358},
                {"id":7,"name":"Marshall","mobile":9276107621},
                {"id":8,"name":"May","mobile":9966279627},
                {"id":9,"name":"Villanueva","mobile":9695365778},
                {"id":10,"name":"Gonzalez","mobile":9946879817},
                {"id":11,"name":"Dorsey","mobile":9243595415}
            ];
      private onRowClick(row:any){
        console.log(row);
        alert("selected row:"+ row.id +" "+row.name+" "+row.mobile);
      }
  }

Config Options

The following config options can be used

| Setting |Type | Description | |:--- |:--- |:--- |:--- | | title | String | Set the title of the table | | w | Number | Set the width of the table. | | h | Number | Set the height of the table. | | itemHeight | Number | Set the height of the row. | | totalRows | Number | Total number of records. | | items | Array | Array of table records. | | sort | Object | Object to set the default column for sorting.|

Column Template

Custom content or elements can be added to table columns.

  • <c-column> - Column component for the table.
  • Example:
    <cuppa-datagrid [datalist] = "arrayList" [config]="config">
          <c-column field="id"></c-column>
          <c-column field="name">
            <ng-template let-person="rowData">
                <span>{{person.name}}</span>
            </ng-template>
          </c-column>
          <c-column field="mobile"></c-column>
          <c-column>
            <ng-template let-person="rowData">
                <button class="btn btn-default btn-success" (click)="getRowData(person)">Get Row</button>
            </ng-template>
          </c-column>
      </cuppa-datagrid>

Heading Template

The table heading can be customised with the <c-heading> tag. The following example show how to use a font awesome icon with text in the title section. -Example:

        <cuppa-datagrid [datalist] = "arrayList" [config]="config">
          <c-heading>
            <ng-template> 
              <span class="fa fa-list"></span>
              <b>Heading Template</b>
            </ng-template>
          </c-heading>
      </cuppa-datagrid> 

Events

  • onRowSelect - Return the clicked row object.

    Example : (onRowSelect)="onRowClick($event)"

Thats all Folks !! You are good to go.

Please raise any issues here

To run the code and build in your local, follw the below steps

  • git clone https://github.com/CuppaLabs/angular2-dataGrid.git
  • npm install
  • ng serve
  • Go to http://localhost:4200 where your app will run.

Licence

This project is licensed under the MIT license. See the LICENSE file for more info.

--

The MIT License (MIT) Copyright (c) 2016 Cuppa Labs

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Author

Pradeep Kumar Terli @ Cuppa Labs