2.1.21 ā€¢ Published 4 years ago

ngx-table-manager v2.1.21

Weekly downloads
142
License
MIT
Repository
github
Last release
4 years ago

Angular Table Manager

šŸ‘Øā€šŸ« Try the demo!

āš” Edit on Stackblitz!

šŸ‘Øā€šŸ”§ Generate your models here!

Imgur Imgur Imgur

Features:

  • Quick search
  • Advanced search
  • Column managing (column order, visibility, sticky on horizontal scroll)
  • Sorting
  • Customizable button columns (With their own events)
  • Selection (multiple and single)
  • Easy editing and customization

Components:

  • ngx-table: Basic data table.
  • ngx-table-manager: Table manager, it provides the search and sort fuctions.
  • ngx-tm-select: Dropdown select filter, for specific calumn with custom or unique data from the column.

Getting started

Installation:

Install via npm package manager

npm i ngx-table-manager

Prerequisites:

npm i -s @angular/flex-layout
ng add @angular/material
npm i ngx-color-picker

Usage:

Module:

Import ngx-table-manager

import { TableManagerModule } from  'ngx-table-manager';
@NgModule({

imports: [ TableManagerModule ]
})

HTML:

Add ngx-table-manager

  <!-- DROPDOWN FILTER - FOR COLUMN 'TYPE' -->
   <ngx-tm-select
      style="margin: 10px;"

      [input]="tsTest"
      [column]="'type'"
      [name]="'Type'"

      (output)="selectTest($event)"
      >
    </ngx-tm-select> 

    <!-- TABLE MANAGER WITH SEARCH AND ADVANCED SEARCH -->
    <ngx-table-manager
      style="margin: 10px;"

      [input]="tsTest" 
      [selectedColor]="'red'"
      [advencedSearch]="true"
      [fastSearch]="true"
      [displayColumns]="true"
      [inputSearch]="true"
      [startSearch]="true"
      [columnSticky]="true"
      [colorPickerText]="true"
      [colorPickerBackground]="true"

      (output)="onSearchTest($event)"  
      (dispColsSelect)="onDispColsSelect($event)"
      >
      </ngx-table-manager>
  
    <!-- MATERIAL TABLE -->
    <ngx-table
      fxFlex 
      style="height: 100%;"
      
      [input]="tsTest" 
      [isRowSelect]="true"
      [numberFormat]="numberFormat"
      [loading]="loading"
      [rowColor]="true"
      [columnSearch]="true"
      [resizable]="true"

      (output)="onEvent($event)"
      (scroll)="onTableScroll($event)"
    >
    </ngx-table>

TypeScript:

import { Component, OnInit } from '@angular/core';
import { TableSort } from 'projects/table-manager/src/lib/models/table-sort';
import { TestCols } from '../app/models/table-cols/test.json';
import { DATA } from './models/datat';
import { TableManagerService, ExtraCols, Select, Relations } from 'projects/table-manager/src/public-api';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {

  // ngx-table, ngx-table-manager
  tsTest: TableSort;

  // ngx-tm-select
  arrSelectTest = [
    { key: 1, value: 'test1' },
    { key: 2, value: 'test2' }
  ];

  // ngx-table
  extraCols = [];
  select;
  isRowSelect;
  numberFormat;
  loading = true;

  arrEc: Array<ExtraCols>;
  s: Select;

  constructor(
    private tmService: TableManagerService
  ) {

    // SET MEMBERS:
    const search = { title: 'Name', name: 'name', show: true, sticky: false };
    this.tsTest = new TableSort(null, null, null, null, null, null, false, search);

    this.tsTest.setSelect = {
      type: 'select',
      multi: true,
      filter: [
        { col: 'type', value: ['a', 'b'], relation: Relations.eq }
      ]
    };

    this.tsTest.setExtraCols = [
      {
        type: 'edit',
        icon: 'edit',
        filter: [
          { col: 'name', value: ['test1', 'test2'], relation: Relations.eq }
        ]
      },
      {
        type: 'del',
        icon: 'delete',
        style: {
          color: '#FF6859'
        },
        tooltip: 'Delete'
      }
    ];

    this.numberFormat = '1.0-2';
    this.isRowSelect = true;
  }

  /**
   * Call load data on init. Simulate API request.
   */
  ngOnInit() {

    setTimeout(() => {
      this.loadData();

    }, 3000);
  }

  /**
   * Get data from local DATA. (replace this with your request.)
   */
  loadData() {
    this.tsTest.refresh(JSON.parse(JSON.stringify(DATA)));
    this.loading = false;
  }

  /**
   * Set tsTest to search result.
   * @param searchObj Search result.
   */
  onSearchTest(searchObj: TableSort) {
  }

  /**
   * Output event.
   * @param event edit, del, select, selectAll.
   */
  onEvent(event) {
    console.log(event);
  }

  /**
   * ngx-tm-select selection change.
   * @param selectObj Search result.
   */
  selectTest(selectObj: TableSort) {
  }

  // Toggle selectable
  btnToggle() {

    if (this.tsTest.getSelect) {
      this.tsTest.setSelect = null;
    } else {
      this.tsTest.setSelect = {
        type: 'select',
        multi: true,
        filter: [{ col: 'type', value: ['a', 'b'], relation: Relations.eq }, { col: 'id', value: [5], relation: Relations.gt }],
      };
    }
  }

  // Refresh data
  btnRefresh_Click() {
    DATA.push({
      id: 200,
      name: 'test101',
      number: 33333,
      text: 'ewwqrwq',
      type: 'i'
    });

    this.tsTest.refresh(JSON.parse(JSON.stringify(DATA)));
  }

  /**
   * Close column select dialog.
   * @param event Returns the cols. data.
   */
  onDispColsSelect(event) {
    console.log(event);
    this.tsTest.arrCols = event;
  }

  onTableScroll(event) {
    console.log(event);
  }


}
  • You can generate your column model with our model generator or you can leave it as null and the table manager class will generate it for you!

Columns:

{
    "TestCols": [
        {
            "title": "Id",
            "name": "id",
            "show": true,
            "sticky": false,
            "search_value": "",
            "style": {},
            "format": "number"
        },
        {
            "title": "Name",
            "name": "name",
            "show": true,
            "sticky": false,
            "search_value": "",
            "style": {},
            "format": "string"
        },
        {
            "title": "Type",
            "name": "type",
            "show": true,
            "sticky": false,
            "search_value": "",
            "style": {},
            "format": "string"
        },
        {
            "title": "Text",
            "name": "text",
            "show": true,
            "sticky": false,
            "search_value": "",
            "style": {},
            "format": "string"
        }
    ]
}
2.1.21

4 years ago

2.1.19

4 years ago

2.1.18

4 years ago

2.1.17

4 years ago

2.1.16

4 years ago

2.1.15

4 years ago

2.1.13

4 years ago

2.1.12

4 years ago

2.1.11

4 years ago

2.1.10

4 years ago

2.1.9

4 years ago

2.1.8

4 years ago

2.1.4

4 years ago

2.1.6

4 years ago

2.1.5

4 years ago

2.1.7

4 years ago

2.1.3

4 years ago

2.1.2

4 years ago

2.1.0-beta.10

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.1.0-beta.3

4 years ago

2.1.0-beta.5

4 years ago

2.1.0-beta.4

4 years ago

2.1.0-beta.7

4 years ago

2.1.0-beta.6

4 years ago

2.1.0-beta.9

4 years ago

2.1.0-beta.8

4 years ago

2.1.0-beta.2

4 years ago

2.0.1

4 years ago

2.1.0-beta.1

4 years ago

2.0.0

4 years ago

2.0.0-beta.5

4 years ago

2.0.0-beta.4

4 years ago

2.0.0-beta.3

4 years ago

2.0.0-beta.2

4 years ago

2.0.0-beta.1

4 years ago

2.0.0-beta.0

4 years ago

1.1.16

4 years ago

1.1.15

4 years ago

1.1.14

4 years ago

1.1.13

4 years ago

1.1.12

4 years ago

1.1.11

4 years ago

1.1.10

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.1.2

4 years ago

1.0.19

4 years ago

1.0.21

4 years ago

1.0.20

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.3.0

4 years ago

0.3.1

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.0.21

4 years ago

0.0.22

4 years ago

0.0.20

4 years ago

0.0.19

4 years ago

0.0.18

4 years ago

0.0.17

4 years ago

0.0.16

4 years ago

0.0.15

4 years ago

0.0.14

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.10

4 years ago

0.0.11

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago