All Projects → fredguile → Ng2 Md Datatable

fredguile / Ng2 Md Datatable

Licence: mit
Angular 5+ DataTable component for using with Material Design 2

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Ng2 Md Datatable

Vantage Ui Template
Template for UI applications in Vantage
Stars: ✭ 193 (+382.5%)
Mutual labels:  material-design, angular2
Angular5 Example Shopping App
Angular 5 Example Shopping App + Angular Material + Responsive
Stars: ✭ 120 (+200%)
Mutual labels:  material-design, angular2
Origami
Angular + Polymer
Stars: ✭ 158 (+295%)
Mutual labels:  material-design, angular2
Tableview
TableView is a powerful Android library for displaying complex data structures and rendering tabular data composed of rows, columns and cells.
Stars: ✭ 2,928 (+7220%)
Mutual labels:  material-design, datatable
Md2
Angular2 based Material Design components, directives and services are Accordion, Autocomplete, Collapse, Colorpicker, Datepicker, Dialog(Modal), Menu, Multiselect, Select, Tabs, Tags(Chips), Toast and Tooltip.
Stars: ✭ 389 (+872.5%)
Mutual labels:  material-design, angular2
Angular2 Mdl
Angular 2, 4, 5, 6, 7, 8, 9, 10, 11 components, directives and styles based on material design lite (npm: @angular-mdl/core)
Stars: ✭ 562 (+1305%)
Mutual labels:  material-design, angular2
Ngx Datatable
✨ A feature-rich yet lightweight data-table crafted for Angular
Stars: ✭ 4,415 (+10937.5%)
Mutual labels:  datatable, angular2
Bootstrap
Open Source JS plugins
Stars: ✭ 13 (-67.5%)
Mutual labels:  material-design, angular2
Angular2 Social Login
Simple client side social authentication for Angular2 application.
Stars: ✭ 34 (-15%)
Mutual labels:  angular2
Gdynet
Unsupervised learning of atomic scale dynamics from molecular dynamics.
Stars: ✭ 37 (-7.5%)
Mutual labels:  material-design
Ng2 Ace
A basic ace editor directive for angular 2.
Stars: ✭ 33 (-17.5%)
Mutual labels:  angular2
Postgraduation
University management platform dedicated for post-graduation in computer science field using django rest framework.
Stars: ✭ 35 (-12.5%)
Mutual labels:  material-design
Dejajs Components
Angular components
Stars: ✭ 37 (-7.5%)
Mutual labels:  angular2
Materialdesign Login Register Forgot Html
3 Simple forms ( login , register , forgot password ), using beautifull material design components.
Stars: ✭ 34 (-15%)
Mutual labels:  material-design
Alfred Mdi
Alfred 3 workflow to find Material Design Icons
Stars: ✭ 38 (-5%)
Mutual labels:  material-design
Jtmaterialtransition
An iOS transition for controllers based on material design.
Stars: ✭ 966 (+2315%)
Mutual labels:  material-design
Wanandroid jetpack
玩安卓的Jetpack版本
Stars: ✭ 33 (-17.5%)
Mutual labels:  material-design
Quasar Awesome
🎉 A list of awesome things related to Quasar
Stars: ✭ 995 (+2387.5%)
Mutual labels:  material-design
Material Cab
🚕 An Android & Kotlin library for placing and manipulating Contextual Action Bars in your UI.
Stars: ✭ 988 (+2370%)
Mutual labels:  material-design
Angular4 Admin Front
Admin system front based on Angular. 基于Angular4的后台管理系统(no longer maintain)
Stars: ✭ 36 (-10%)
Mutual labels:  material-design

ng2-md-datatable

npm CircleCI downloads

Angular 2 with Material 2 is awesome, but it's still lacking a DataTable component (as of November 2016).

As I urgently needed one for a project, I decided to make my own DataTable component and share it on GitHub. This may be useful for you (or not).

Update 08/2017: You may want to use the official Material DataTable here. But if this one still speaks more to you, no problem I'll keep it up to date with the latest Angular 5+/Material5+ versions.

Features

  • Pagination Component
  • Column sorting (ascending/descending)
  • Row selection (using checkboxes)
  • You can use it with @ngrx/store (that's how I use it)

Working with

  • Angular 5
  • Material 5

Installation

To use ng2-md-datatable in your project install it via npm:

npm install --save ng2-md-datatable

Then include it in your application's main module:

import { MatDataTableModule } from 'ng2-md-datatable';

@NgModule({
  imports: [
    ...
    MatDataTableModule,
    ...

Usage

Your datatable would look like this in a Angular 2 template:

<ng2-md-datatable selectable="true">
  <ng2-md-datatable-header>
    <ng2-md-datatable-column sortableValue="article">Article</ng2-md-datatable-column>
    <ng2-md-datatable-column sortableValue="product">Product</ng2-md-datatable-column>
    <ng2-md-datatable-column sortableValue="quantity" numeric>Quantity</ng2-md-datatable-column>
  </ng2-md-datatable-header>
  <tbody>
    <ng2-md-datatable-row selectableValue="K003-0350-001">
      <td>K003-0350-001</td>
      <td>Yirgacheffe Kaffee, 350g ganze Bohne</td>
      <td class="numeric">232</td>
    </ng2-md-datatable-row>
    <ng2-md-datatable-row selectableValue="K003-0350-002">
      <td>K003-0350-002</td>
      <td>Yirgacheffe Kaffee, 350g gemahlen</td>
      <td class="numeric">124</td>
    </ng2-md-datatable-row>
    <ng2-md-datatable-row selectableValue="K003-0350-003">
      <td>K003-0350-003</td>
      <td>Yirgacheffe Kaffee, 1kg ganze Bohne</td>
      <td class="numeric">464</td>
    </ng2-md-datatable-row>
    <ng2-md-datatable-row selectableValue="K003-0350-004">
      <td>K003-0350-003</td>
      <td>Yirgacheffe Kaffee, 1kg gemahlen</td>
      <td class="numeric">243</td>
    </ng2-md-datatable-row>
  </tbody>
</ng2-md-datatable>

Here's the pagination component:

<ng2-md-datatable-pagination
  [currentPage]="1"
  [itemsPerPage]="5"
  [itemsCount]="700"
  [itemsPerPageChoices]="[5,10,20,50]"
  [itemsPerPageFirstChoice]="10"

  [needShowFirstArrow]="true"
  [needShowLastArrow]="true"
  ofText="of"
  rowsPerPageText="Rows per page:"
  >
</ng2-md-datatable-pagination>

As you might have noticed, these two components are not initially linked, it is up to you to bind them to your datasource and react to events they fire.

Events

You should subscribe to these event emitters:

src/components/datatable.component.ts

@Output() selectionChange: EventEmitter<DatatableSelectionEvent>;
@Output() sortChange: EventEmitter<DatatableSortEvent>;

src/components/datatable-pagination.component.ts

@Output() paginationChange: EventEmitter<DatatablePaginationEvent>;

Please read src/common/events/*.ts for details about the payload of each event.

Theming

To add ng2-md-datatable to your Material 2 theming file:

@import '~ng2-md-datatable/datatable-theme';
...
@include mat-datatable-theme($theme);

This is based on the current guide for theming components with Material RC.

Live Demo

To see ng2-md-datatable in action, head to /demo-app and:

  • you need Angular-CLI v1.0 or later (npm install -g @angular/cli)
  • from the demo-app folder, run npm install
  • then start ng serve or ng serve --aot

Don't mind about the use of Observables here (and about the Shuffle button), I just wanted to test if the datatable behaved correctly with Angular async rendering.

Plunkr

Or you can open this Plunkr: https://plnkr.co/edit/QQgr9b9HZLGjN1iDJqiy?p=preview

It's pretty much the same code than then demo-app.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].