Giter Site home page Giter Site logo

vitocmpl / ng2-ya-table Goto Github PK

View Code? Open in Web Editor NEW
17.0 2.0 7.0 9.98 MB

Angular yet another table

Home Page: https://vitocmpl.github.io/ng2-ya-table/

License: MIT License

TypeScript 87.63% JavaScript 2.74% HTML 7.60% CSS 0.09% Shell 0.09% SCSS 1.84%
table angular2 angular-2 ng2 sort pagination filter bootstrap3 bootstrap server-side

ng2-ya-table's Introduction

ng2-ya-table

Angular yet another table with pagination, ordering, filtering and datasource server-side ready.

Demo

Live Demo

alt tag

Installation

Minimal Setup Example

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { Ng2YaTableModule } from 'ng2-ya-table';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    Ng2YaTableModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
<!-- You can now use the library in app.component.html -->
<h1>
  {{title}}
</h1>
<ng2-ya-table [options]="options" [columns]="columns" [datasource]="data" [paging]="paging">
    <ng-template ng2YaTableCellTemplate="btnEdit" let-data='data' let-row='row'>
      <div class='text-center'>
        <button type='button' class='btn btn-sm btn-primary' (click)="onActionClick(row.id)">Edit</button>
      </div>
    </ng-template>
    <ng-template ng2YaTableCellTemplate="btnDelete" let-data='data' let-row='row'>
      <div class='text-center'>
        <button type='button' class='btn btn-sm btn-danger' (click)="onActionClick(row.id)">Delete</button>
      </div>
    </ng-template>
</ng2-ya-table>
public options: TableOptions = {
    orderMulti: false,
    className: ['table-striped'],
    language: "en"
};

public data: unknown[] = [...]; //array of data

public paging: TablePaging = {
    itemsPerPage: 10,
    itemsPerPageOptions: [10, 25, 50, 100],
    maxSize: 5
}

public columns: TableColumn[] = [
{ 
    title: 'Name', 
    name: 'name', 
    sort: true, 
    sortOrder: 'asc',  
    filter: {
        controlType: 'default',
        config: {
            placeholder: 'Filter by name'
        }
    } 
},
{ 
    title: 'Username', 
    name: 'username', 
    sort: true, 
    filter: {
        controlType: 'default',
        config: {
            placeholder: 'Filter by username'
        }
    } 
},
{ 
    title: 'Email', 
    name: 'email', 
    sort: true, 
    filter: {
        controlType: 'default',
        config: {
            placeholder: 'Filter by email'
        }
    } 
},
{ 
    sort: false, 
    title: '', 
    name: 'btnEdit',
    width: "10px"
},
{ 
    sort: false, 
    title: '', 
    name: 'btnDelete',
    width: "10px"
}];

Server-Side datasource Setup Example

<ng2-ya-table [options]="options" [columns]="columns" [datasource]="datasource" [paging]="paging">
</ng2-ya-table>
public datasource: TableDataSource = (request: DatasourceParameters): Observable<DatasourceResult> => {
    return this.service.getUsers(request);
}

Further Documentation

Installation, customization and other useful articles will be available soon...

Features

  • Observable data source (client-side or server-side)
  • Filtering
  • Sorting
  • Pagination
  • Bootstrap 4 / 5 layout

License

MIT license.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.